Device
udev
udev (userspace /dev
)
/dev
is static, udev
is for plugable devices running in userspace.
To be able to deal with peripheral devices that are hotplug-capable in a user-friendly way, a part of handling all of these hotplug-capable hardware devices was handed over from the kernel to a daemon running in user-space. Running in user space serves security and stability purposes.
udev
primarily manages device nodes in the /dev
directory, Unlike traditional Unix systems, where the device nodes in the /dev
directory have been a static set of files, the Linux udev
device manager dynamically provides only the nodes for the devices actually present on a system.
$ ps -e | grep udevd
304 ? 00:00:00 systemd-udevd
$ ps -e | grep systemd
304 ? 00:00:00 systemd-udevd
1317 ? 00:00:00 systemd-logind
Check attacked EBS(sda/sdf may be renamed to xvda/xvdf)
$ sudo fdisk -l
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/xvda1 doesn't contain a valid partition table
Disk /dev/xvdf: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Format EBS
$ sudo mkfs -t ext4 /dev/xvdf
Edit fstab and reboot
$ vi /etc/fstab
or manually mount
# mkdir /mnt/tmp
# mount /dev/xvdf /mnt/tmp
# umount /dev/xvdf
XFS
$ sudo apt-get install xfsprogs
$ sudo mkfs.xfs /dev/sdf
$ sudo mount -t xfs -o defaults /dev/sdf /var/www
Mount / Umount
Assume a device is added as /mnt/vdc
. Create new folder as /dev/vdc
$ sudo mkdir /dev/vdc
Edit /etc/fstab
.
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/vdc /mnt/vdc auto defaults 0 0
Mount all
$ sudo mount -a
Check by df
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vdc 65390 36 65354 1% /mnt/vdc
To remount
$ mount -o remount /dev/vdc
Mount disk
$ mount /dev/sdf /mnt/workspace
umount: it seems [device] is mounted multiple times
Error:
$ umount /dev/[device]
umount: it seems /dev/<device> is mounted multiple times
Solution: use sudo
$ sudo umount /dev/[device]
Format a Device
Use mkfs.ext2
, mkfs.ext3
, mkfs.ext4
etc
$ sudo mkfs.ext3 /dev/<device>
Check FS
# df -hT | awk '{print $1,$2,$NF}' | grep "^/dev"
/dev/sda3 ext4 /
/dev/sda2 ext2 /boot
/dev/sda6 ext4 /tmp
/dev/sdb1 ext4 /data1
/dev/sdc1 ext4 /data2
/dev/sdd1 ext4 /data3
cmd
- mkfs
- mke2fs
- tune2fs
- mkswap
mke2fs -F -j /dev/sdh mkdir /ebs mount /dev/sdh /ebs
copy to ebs:
dd bs=65536 if=/dev/sda1 of=/dev/sdh
fsck /dev/sdh
check
df -h
fsck /dev/sdh