![]() | Red Hat Certified System Administration 8 |
Chapter 14: Managing StorageGoalTo create and manage disks, partitions, and file systems from the command line.SommaireDisksDisks/dev/sda A hard disk that uses the SCSI driver. Used for SCSI and SATA disk devices. Common on physical servers but also in VMware virtual machines. /dev/hda The (legacy) IDE disk device type. You will seldom see this device type on modern computers. /dev/vda A disk in a KVM virtual machine that uses the virtio disk driver. This is the common disk device type for KVM virtual machines. /dev/xvda A disk in a Xen virtual machine that uses the Xen virtual disk driver. You see this when installing RHEL as a virtual machine in Xen. RHEL 7 cannot be used as a Xen hypervisor, but you might see RHEL 7 virtual machines on top of the Xen hypervisor using these disk types. /dev/nvme As you can see, all disk device names end with the letter a. That is because it is the first disk that was found in your server. The second SCSI disk, for instance, would have the name /dev/sdb. If many disks are installed in a server, you can have up to /dev/sdz and even beyond. After /dev/sdz, the kernel continues creating devices with names like /dev/sdaa and /dev/sdab. File SystemsFile SystemsXFS The default file system in RHEL 7. Ext4 The default file system in previous versions of RHEL. Still available and supported in RHEL 7. Ext3 The previous version of Ext4. On RHEL 7, there is no real need to use Ext3 anymore. Ext2 A very basic file system that was developed in the early 1990s. There is no need to use this file system on RHEL 7 anymore. BtrFS A relatively new file system that was not yet supported in RHEL 7.0 but will be included in later updates. NTFS Not supported on RHEL 7. VFAT A file system that offers compatibility with Windows and Mac, it is the functional equivalent of the FAT32 file system. Useful to use on USB thumb drives that are used to exchange data with other computers but not on a server’s hard disks. PartitionsPartitionsPartitions Creation
Commands[root@redhat ~]# lsblk list disks details[root@redhat ~]# lsblk -f list disks details including filesystems [root@redhat ~]# df show mounted partitions usage [root@redhat ~]# df -h Human View of df Commmand [root@redhat ~]# du show disk usage of directories (du /root) [root@redhat ~]# du -h Human view [root@redhat ~]# du -h /home/user1 Example [root@redhat ~]# blkid The blkid command gives an overview of existing partitions with a file system on them and the UUID of the filesystem, as well as the file system used to format the partition. [root@redhat ~]# blkid partition Mount an image on a device[root@redhat ~]# dd if=image.iso of=special_file[root@redhat ~]# dd if=image.img of=special_file Removable Storage Devices /run/media/user/label Clone Device[root@lab ~]# cat /dev/sda > /dev/sdb![root@lab ~]# dd if=/dev/sda of=/dev/sdb more efficient gdisk used for operating on GPT Partitions [root@lab ~]# gdisk /dev/disk Operate on disk[root@lab ~]# gdisk /dev/partition Operate on partition VolumesVolume is a disk partition formated with a filesystem . Before using a disk partition to store files, we must :
Format PartitionSyntax[root@lab ~]# mkfs.filesystem –b blocksize partition format a partition [+] exple: [root@lab ~]# mkfs.ext2 –b 2048 /dev/sda3 Mount a Volume[root@redhat ~]# mount show mounted devices[root@redhat ~]# mount specialfile mountdirectory [root@redhat ~]# mount –o loop ISOfile mountdirectory [root@redhat ~]# umount mountdirectory [root@redhat ~]# mount -av monte tous les volumes specifies dans /etc/fstab Volume SettingsUUIDLABEL [root@redhat ~]# e2label partition label : Make label for an EXT Volume ![]() [root@redhat ~]# xfs_admin -L label partition-file : Make label for an XFS Volume ![]() Volumes AutomountingWe need to configure /etc/fstab file to automount a Volume (Automatically mount when System boots)Check Disk Partition[root@redhat ~]# fsck specialfile brief check of disk[root@redhat ~]# fsck /dev/sdg1 brief check of disk [root@redhat ~]# xfs_repair partition brief check of xfs partition [root@redhat ~]# xfs_repair /dev/sdg1 brief check of xfs partition Files/mnt/ : System Default mountpoint directoryDisk UtilitiesDisk UtilitiesfdiskDisks Partitions ToolSyntax[root@redhat ~]# fdisk –l mounted and unmounted partitions list[root@redhat ~]# fdisk partition disk partition command options list [root@redhat ~]# fdisk options device-special-file Options-cu open fdisk console to operate on device-b Specifies the sector size of the disk -h Specifies the number of heads on the disk -l Lists current partition tables Example [root@redhat ~]# fdisk -l /dev/sdb [root@redhat ~]# fdisk -cu /dev/sdb [root@redhat ~]# fdisk -s /dev/sdb //give partition size(s) in blocks 31457280 fdisk /dev/sdb Open fdisk utility to operate on disk [root@redhat ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x52224ffc. fdisk Utility Internal Commandsm : for Helpa toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Create MBR Partitions Create GPT Partitions |