version 1.0.0, 2014-07-06 : Initial version
Filesystems management commands
A cheasheet about classic filesystem managemement commands.1. Basic filesystems operations
fdisk -l
and parted -l
are equivalent but RedHat recommends using parted
over fdisk
.
To force the kernel to reread the partition table, use the partprobe
command.
To convert a filesystem from ext2 to ext3, use
umount /dev/sdb1 tune2fs -j /dev/sdb1
To create a swap partition on /dev/sdc1
mkswap /dev/sdc1 swapon /dev/sdc1 # Last, verify swapon -s
Label a filesystem using:
e2label /dev/sdb1 my_label # Then display the label to verify: e2label /dev/sdb1 # And find the FS from the label findfs LABEL=my_label
Get usefull infos about disks with the blkid
command. Example:
# blkid /dev/sda1: UUID="635f2b90-bb93-4221-88e2-5194a004aa52" TYPE="ext4" /dev/sda2: UUID="4DmlAr-kOMB-0s17-GSxv-t0Sl-3fF2-Vqo6Of" TYPE="LVM2_member" /dev/sdc1: UUID="187b93af-44c4-a179-06ae-2b7759e32205" UUID_SUB="71fee50b-4b50-4ce7-7a97-901b9a76e079" LABEL="RHEL01:0" TYPE="linux_raid_member" /dev/sdb1: UUID="187b93af-44c4-a179-06ae-2b7759e32205" UUID_SUB="f164f4f6-d529-3d8e-93ef-ee6d5ae1870b" LABEL="RHEL01:0" TYPE="linux_raid_member" /dev/sdd1: UUID="187b93af-44c4-a179-06ae-2b7759e32205" UUID_SUB="bbf9f4a1-1cca-5b1a-df4f-9eabe1e72a32" LABEL="RHEL01:0" TYPE="linux_raid_member" /dev/mapper/VolGroup-lv_root: UUID="50eb8ea8-3c11-46c3-80c5-68a57075170a" TYPE="ext4" /dev/mapper/VolGroup-lv_swap: UUID="c9ca22fc-fe01-4ee9-8607-66892a4aa794" TYPE="swap"
2. About XFS filesystems
XFS is now the default file system for RHEL7.
In RHEL 6.5, the /boot
CANNOT be other than ext* file systems. Grub does not
support vFAT, Btrfs, XFS or even LVM, so you can’t use thoses for /boot
.
To create an XFS file system, you need to install the xfsprogs anc xfsdump
packages (yum install -y xfsdump xfsprogs
). Then the process would look quite
familiar:
# We don't use LVM here, but you can! So let's create a new /dev/sdd1 # You can choose type 83, mkfs.xfs will do the rest fdisk /dev/sdd mkfs.xfs /dev/sdd1 mkdir /media/test_xfs mount /dev/sdd1 /media/test_xfs # Then update fstab echo -e "$(blkid /dev/sdd1 | cut -d" " -f2) \t /media/test_xfs \t xfs \t defaults \t 1 \t 1" >> /etc/fstab
3. Permissions
The setuid flag (chmod u+s file
or chmod 4755 file
) is used to allow multiuser
access, meaning that when running the file, the process running the file will be
the owner of the file, not the user that launched it.
The setgid flag (chmod g+s folder
or chmod 2770 folder
) is used to allow
multigroup access, meaning that the owner of the folder won’t be able to access
the directory if not in the group that owns the file and that all files created
in this folder will all be accessible in read/write to any member of the
folder’s group owner.
The sticky bit flag (chmod o+t file
or chmod 1775 file
) prevents accidental
delete by users or groups even if they have read/write access. Only root or the
owner of the file (or directory) can delete it.