- Attach (Via AWS Management Console)
- Format (Add FileSystem/Format Disk/Format Volume)
- Mount (Make new Disk available under a name)
- Automatic Mount after Reboot - Edit "/etc/fstab" File
- Find list of all devices attached to System
- lsblk -fa
- du -h
- Find out which device is unMounted - Device not having Mount Path
- FInd out if that Unmounted(Only Attached, Not Mounted) Device is Blank or has Data within it.
- sudo file -s /dev/xvdf
- Attached Disk can be readonly like a Bootable CD or It can be blank
- If The Attached Disk is having no data/raw/blank - Format it and add Filesystem to it ,
- If the output shows simply
data
, as in the following example output, there is no file system on the device - Use "mkfs" command to create a Filesystem or Format a disk
- sudo mkfs -t xfs /dev/xvdf
- Mount the Disk using below command, mount <Device_Name> <Mount_Path>
- sudo mount /dev/xvdf /data
- Once we mount disk on a label, We need to edit "/etc/fstab" file to make sure that When we reboot System, We can mount these disks automatically under specified names
- vi /etc/fstab
- Find out <DEVICE_ID> using "blkid"
- blkid
NFS (Network File System) is a distributed filesystem protocol that allows us to share remote directories over a network.
To mount an NFS share, we must install the NFS client package first.
Let’s say we have a well-configured NFS shared directory “/export/nfs/shared” on a server 192.168.0.8.
Similar to the Samba share mount, we first create the mount point and then mount the NFS share:
root# mkdir /mnt/nfsShare
root# mount -t nfs 192.168.0.8:/export/nfs/shared /mnt/nfsShare
root# mount | grep nfsShare
192.168.0.8:/export/nfs/shared/ on /mnt/nfsShare type nfs (rw,addr=192.168.0.8)
3.5. Commonly Used mount -o Option
The mount command supports many options.
Some commonly used options are:
- loop – mount as a loop device
- rw – mount the filesystem read-write (default)
- ro – mount the filesystem read-only
- iocharset=value – character to use for accessing the filesystem (default iso8859-1)
- noauto – the filesystem will not be mounted automatically during system boot
3.6. The /etc/fstab FileSo far, we’ve seen several examples of the mount command to attach to various filesystems. However, the mounts won’t survive after a reboot.
For some filesystems, we may want to have them automatically mounted after system boot or reboot. The /etc/fstab file can help us to achieve this.The /etc/fstab file contains lines describing which filesystems or devices are to be mounted on which mount points, and with which mount options.
All filesystems listed in the fstab file will be mounted automatically during system boot, except for the lines containing the “noauto” mount option.
Let’s see an /etc/fstab example:
$ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sdb1 / ext4 rw,defaults,noatime,commit=120,data=ordered 0 1
/dev/sdb2 /home ext4 rw,defaults,noatime,data=ordered 0 2
/dev/sda3 /media/Backup ntfs-3g defaults,locale=en_US.UTF-8 0 0
/dev/sda2 /media/Data ntfs-3g defaults,locale=en_US.UTF-8 0 0
...
Thus, if we add the following line in this file, the archLinux.iso image will be automatically mounted on /mnt/archIso after system boot:
/media/Data/archLinux.iso /mnt/archIso udf ro,relatime,utf8 0 0
Once a filesystem is mentioned in /etc/fstab, we can mount it by just giving the mount point or the device.
For instance, with the above fstab configuration, we can mount the /dev/sda2 partition with either of the two short commands:
root# mount /media/Data
or
root# mount /dev/sda2
4. Unmounting a Filesystem
The umount command notifies the system to detach the given mounted filesystems. We just provide the filesystem name or the mount point following the umount command.
For example, if we want to unmount the previously mounted USB stick and ISO image:
root# umount /dev/sdd1
root# umount /mnt/archIso
We can also umount multiple mounted filesystems in one shot:
root# umount /dev/sdd1 /mnt/archIso
4.1. Lazy UnmountWhen we want to umount a filesystem, we don’t always know if there are operations still running on it. For instance, a copy job could be running on the filesystem.
Of course, we don’t want to break the copy and get inconsistent data. The option -l will let us do a “lazy” umount.
The -l option informs the system to complete pending read or write operations on that filesystem and then safely unmount it:
root# umount -l mount_point
4.2. Force UnmountIf we pass -f option to the command umount, it’ll forcefully unmount a filesystem even if it’s still busy:
root# umount -f mount_point
We should be careful while executing umount with -f as it could lead to corrupt or inconsistent data in the unmounted filesystem.
One real-world use case for force unmounting could be unmounting a network share because of a connection problem.
-------------------------------------------------------------------------------------
[root@ip-172-31-58-120 ec2-user]# blkid /dev/xvda1: LABEL="/" UUID="74fc4c15-c86f-4c31-92f6-0df873546b85" TYPE="xfs" PARTLABEL="Linux" PARTUUID="ed868158-eb4b-43a5-8ed5-8b58aa998193" /dev/xvdf: UUID="2008-11-19-03-48-46-00" LABEL="CDROM" TYPE="iso9660" PTUUID="4971ec01" PTTYPE="dos"
[root@ip-172-31-58-120 ec2-user]# lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT xvda xvda1 xfs / 74fc4c15-c86f-4c31-92f6-0df873546b85 / xvdf iso9660 CDROM 2008-11-19-03-48-46-00 /media/census
[root@ip-172-31-58-120 census]# cat /etc/fstab UUID=74fc4c15-c86f-4c31-92f6-0df873546b85 / xfs defaults,noatime 1 1 UUID=2008-11-19-03-48-46-00 /media/census iso9660 defaults 0 0
No comments:
Post a Comment