We partitioned the drives,with the number of utilities.
As creating filesystems,various on those.
After we create some partitions for you,we are know planning to learn to create manually and
automatically mount the devices,once they have been formatted and we have to create the
mount points and will take a look what options we have for mount.
So lets get the list of the disk:
/dev/xvde1 1 766 6144000 83 Linux
Partition1 does not end on cylinder boundary
/dev/xvde2
Partition 2 does not end on cylinder boundary
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Disk /dev/xvdj: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Disk /dev/xvdg: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
[ root@la ~]#
what are available to use:
[ root@la ~]# fdisk /dev/xvdf
Device contains neither a valid DOS partition table
Warning: invalid flag 0x0000 of partition table 4
WARNING: DOS-compatible mode is deprecated.
Command (m for help):
now, we are using the fdisk.
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
now if printout the disk details,now I don’t have any partitions on the system.
Going to define the new partition:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using défault value 1
Last cylinder, + cylinder or +size{K,M,G} (1-2610 , default 2610)
now, when i printed out:
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Device Boot Start End Blocks Id system
/dev/xvdf1 1 654 5253223+ 83 Linux
Command (m for help):
now we are planning to do this for three times, now we have three things to mount to the devices.
Now we have created three partitions:
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Device Boot Start End Blocks Id system
/dev/xvdf1 1 654 5253223+ 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (655-2610, default 655):
Using défault value 655
Last cylinder, + cylinder or +size{K,M,G} (655-2610 , default 2610)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1309-2610, default 1309):
Using défault value 1
Last cylinder, + cylinder or +size{K,M,G} (1309-2610 , default 2610)
now,when you print out that,you can see three partitions:
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Device Boot Start End Blocks Id system
/dev/xvdf1 1 654 5253223+ 83 Linux
/dev/xvdf2 655 1308 5253223+ 83 Linux
/dev/xvdf3 1309 1962 5253223+ 83 Linux
we have to write that and when we do the fdisk –l /dev/xvdf,we can see the list of partitions to
that disk.
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
[ root@la ~]# fdisk -l /dev/xvdf
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000000000
Device Boot Start End Blocks Id system
/dev/xvdf1 1 654 5253223+ 83 Linux
/dev/xvdf2 655 1308 5253223+ 83 Linux
/dev/xvdf3 1309 1962 5253223+ 83 Linux
[ root@la ~]#
first one,we partitioned the disk and with three partitions:
and the second one is the,now we need to do the format :
[ root@la ~]# mkfs -t ext4 /dev/xvdf1
mke2fs 1.41.12
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
stride=0 blocks, stripe width=0 blocks
328656 inodes, 1313305 blocks
65655 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
8016 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing node tables: done
Creating journal (32768 blocks):
we are formatting this as the ext4 partition.
And the next two we format is the ext3,
we created partitions
we created filesystems
and mounted on each one of them.
root@la ~]# mkfs -t ext4 /dev/xvdf2
mke2fs 1.41.12
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
stride=0 blocks, stripe width=0 blocks
328656 inodes, 1313305 blocks
65655 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
8016 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing node tables: done
Creating journal (32768 blocks):
root@la ~]# mkfs -t ext3 /dev/xvdf2
mke2fs 1.41.12
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
stride=0 blocks, stripe width=0 blocks
328656 inodes, 1313305 blocks
65655 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
8016 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing node tables: done
Creating journal (32768 blocks):
[ root@la ~]# mkfs -t ext3 /dev/xvdf3
mke2fs 1.41.12
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
stride=0 blocks, stripe width=0 blocks
328656 inodes, 1313305 blocks
65655 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
8016 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing node tables: done
Creating journal (32768 blocks):
there are couple of ways,unless I am going to assigning these partitions to mount during the
boot process,for one of the what we called the core system directories.
Anything that is under the root partitions:
It is possible for me to do ,temporarily mount the partition.
Copy all of the home directory,over to it. And add that partition in the /etc/fstab.
Rename that home directory as a home2.
And then mount the new filesystem I copied everything,to under the home directory mount it
becomes the part of the root filesystem.
Generally,why you go through the installations,you map out how you architecture the disk,but
it is used for,it is used to avoid the scenarios like,you have to swap disks out,we are going to use
them,in couple of different purposes.
First we will called for mounting as removable filesystem.
General purpose filesystems for cd’s,dvd’s or usb keys there is a media directory.
[ root@la ~]# cd /media
[ root@la ~]# ll
0
[ root@la media ]#
[ root@la ~]# ll
0
[ root@la media ]#
rightnow,there is nothing mounted here.
There is an another filesystem systemdirectory called /mnt.
This is an generalpurpose directory and this is often used for mounting disks and partitions that
are not part of the core filesystem installation or with in the root file structure of the OS.
It’s for backup or the data or the data drive,that is the link through inside of the directory.
So it’s really mount the data,but someone’s home directory.someone ‘s home user and there
are link to that data directory.
It’s part of the home directory,but it is not real.
How do we mount it?
We mount partitions,that are been formatted,now if I just issue the mount command.
[ root@la mnt]# mount
/dev/xvde1 on / type ext4 (rw)
proc on /proc type proc (rw)
syses on /sys type syses (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmps on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[ root@la ~]#
it’s listing,everything mounted on the system.including the sudo or dummy filesystem.
And that is read from the couple of different places on the system,there are two places on your
system,with out excluding we can find,the filesystems mounted on your host:
[ root@la mnt]# cat /etc/mtab
/dev/xvde1 / ext4 w 0 0
proc on /proc type proc (rw) 0 0
syses on /sys type syses (rw) 0 0
devpts on /dev/pts type devpts (rw,gid=5,mode=620) 0 0
tmps on /dev/shm type tmpfs (rw) 0 0
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 0 0
[ root@la mnt]#
that has similar information,to what we are reading,when we are excuting the mount
command.
We can also get this information,from another filesystem:
The procfs sudo filesystem.
[ root@la mnt]# cat /proc/mounts
rootfs / rootfs rw 0 0
/proc /proc proc rw ,relatime 0 0
/sys /sys syses rw, relatime 0 0
udev /dev devtmpfs rw, relatime,gid=5,mode=620
temps /dev/shm tmpfs rw, relatime 0 0
/dev/xvde1 / ext4 rw,relatime,barrier=1,data=ordered 0 0
/proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
none /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 0 0
they both contained the information,the mounts on our system.
I can hide the mount,that I manually make from the point of the /etc/proc/mount and but the
point from the /etc/mtab we cannot hide the mount.
It is controlled by the kernel,so as soon as it sees the mount on the filesystem,it immediately
gives the information.
However the /proc mount is read by the mount command.
[ root@la mnt]# cat /etc/fstab
LABEL=/ / ext4 defaults 0 0
LABEL=ebs-swap none swap sw 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
[ root@la mnt]#
this is,what we determines,when we see the:
[ root@la mnt]# df -h
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
what we mounted on our filesystem.
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
none 0 0 0 - /proc/sys/fs/binfmt_misc
we can see,we configured drive with a label:
just / which is our root drive
/ mounted in this location
with the type of filesystem:ext4
then we will get tp the last part of the stuff in couple of mins.
This file help us to know how and why you mounted the filesystem.
We defined multiple filesystem we define in /etc/fstab.
Mount -a
Will read everything,that is defined in the /etc/fstab.
Samba and nfs are remote filesystems.
We can also,can cause of the drive run:issuing a mount –f
[ root@la mnt]# mount -f
/dev/xvde1 / ext4 w 0 0
proc on /proc type proc (rw) 0 0
syses on /sys type syses (rw) 0 0
devpts on /dev/pts type devpts (rw,gid=5,mode=620) 0 0
tmps on /dev/shm type tmpfs (rw) 0 0
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 0 0
[ root@la mnt]#
defines everything there In the /proc/mount directory.
I can also mount things in the read only mode.
[ root@la mnt]# mkdir part1 part2 part3
[ root@la mnt]# ll
total 12
xxxxxxxxxxxxxxx part1
xxxxxxxxxxxxxxx part2
xxxxxxxxxxxxxxx part3
[ root@la mnt]#
we are going to show,if you try to unmount the filesystem which is in use:
[ root@la mnt]#
[ root@la mnt]# mount -t ext4 /dev/xvdf1 /mnt/part1
this is the absolute path,as we are in the mount directory.
It is better to be using the absolute path.
[ root@la mnt]# df -h
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf1 5.0G 139M 4.6G 3% /mnt/part1
as long as the filesystem type we mentioned,should be match with the partition type
filesystemtype you formatted.
Note
Otherwise you get the error related to the superblock,because superblock contains the
information about the filesystem,it’s inodes and the number of block etc are also about the
filesystem type.
[ root@la mnt]# mount -t ext3 /dev/xvdf2 /mnt/part2
mount: wrong fs type, bad option, bad superblock on /dev/xvdf2
missing codepage or helper program or other error
In some cases useful info is found in syslog - try
dmesg | tail or soyou got this error,because when you formatted the partition type with the filesystem type is ext4
This is the right partition type:
[ root@la mnt]# mount -t ext4 /dev/xvdf2 /mnt/part2
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf1 5.0G 139M 4.6G 3% /mnt/part1
/dev/xvdf2 5.0G 139M 4.6G 3% /mnt/part2
[ root@la mnt]# mount -t ext4 /dev/xvdf3 /mnt/part3
[ root@la mnt]# mount -t ext4 /dev/xvdf3 /mnt/part3
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf1 5.0G 139M 4.6G 3% /mnt/part1
/dev/xvdf2 5.0G 139M 4.6G 3% /mnt/part2
/dev/xvdf3 5.0G 139M 4.6G 3% /mnt/part3
after everything,we have to add to the /etc/fstab.
The best way to mount the system using the UUID.
Universally unique identifier.this is the unique number atleast with the number in the disk.
For any local disk partitions,so that it can be sure,that is unique in the any other disk in the
system and UUID cannot change.
Once the system has detected,the disk the UUID is created by the kernel and written to a
device file to look at.
So,if we go for example and do
root@la part1]# cd /dev/disk
root@la disk]# ll
total 0
xxxxxxxxxxxxxxxxxxx by-label
xxxxxxxxxxxxxxxxxxx by-path
xxxxxxxxxxxxxxxxxxx by-uuid
we can get the list of files.
We can see the UUID’s created for each and every device:
[ root@la disk ]# cd uuid
-bash: cd: uuid: No such file or directory
root@la disk]# ll
total 0
xxxxxxxxxxxxxxxxxxx by-label
xxxxxxxxxxxxxxxxxxx by-path
xxxxxxxxxxxxxxxxxxx by-uuid
root@la disk]# cd by-uuid/
root@la by-uuid]# ll
xxxxxxxxxxxxxxxxxxxx 12e3rrd
xxxxxxxxxxxxxxxxxxxx 12e3rrd
xxxxxxxxxxxxxxxxxxxx 12e3rrd
xxxxxxxxxxxxxxxxxxxx 12e3rrd
there is an another utility in our system,which creates the UUID:
root@la by-uuid]# blkid
/dev/xvde1: LABEL="/" UUID="cb04b2cb-----------------" TYPE="ext4"
/dev/xvde2: LABEL="ebs-swap" UUID="4a4da8eb-58bo-xxxxxxxxxx" "TYPE="swap"
/dev/xvdf1: UUID="2ae774a3-6d6a-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "TYPE="ext3"
/dev/xvdf2: UUID="67er986-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "TYPE="ext3"
/dev/xvdf3: UUID="bd1621dc-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "TYPE="ext3"
root@la by-uuid]#
it will scan complete disks and provide us the UUID information of each and every device.
We will grab the UUID from here and paste this in the /etc/fstab.
UUID FROM THE blkid
Where you want to mount place: /mnt/part1
We have to provide the partition type: ext4
And some values here:
(default or list of common options we have here,made up of read/write,set UUID,these are all
out of scope,now we are using the default,we another option here is the no auto instead of the
default,
This will be used in the scenario,where mounting is part of the job,it is doing backups,the script
will call the mount command manually.
The first column or the first zero mentioned after the default is the dump column
The dump command will not dump the filesystem to file.
The next value is zero,this represents the order you want to check the fsck to perform.
Now non-root filesystems,will genernally set it one.that means it is going to check the,the
root filesystem is checked on boot.
Unmount:
We are doing umount(unmount the filesystem) and we will specify while we are unmounting
by the mount point.
Umount /mnt/part1
So we are unmounting the partition1,
[ root@la mnt]# umount /mnt/part1
[ root@la mnt]# df -h
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf2 5.0G 139M 4.6G 3% /mnt/part2
/dev/xvdf3 5.0G 139M 4.6G 3% /mnt/part3
what happens if you try to umount the partition,when someone is using?
[ root@la mnt]# umount /mnt/part3
umount: /mnt/part3: device is busy.
[ root@la mnt]#
there are number of reasons:
this is because,in another terminal some open the directory and there in that mount point
working on the directory that /mnt/part3,so that it is why it is mentioning as resource is
busy.
The process can lock the directory,because the content are writing in to it.
It is provided a lock in the appropriate run directory.
The kernel is able to understand that the process and associate PID is locked to the particular
directory.
So I will close and stopping working on the /mnt/part3.
And try to umount I can it is working and the result will be seen in the df –h
[ root@la mnt]# df -h
Filesystem Size Used Avail Use% Mountedon
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf2 5.0G 139M 4.6G 3% /mnt/part2
when you try to umount the /mnt/part2
[ root@la mnt]# umount /mnt/part2
umount: /mnt/part2: device is busy.
but it is the device is busy,it is not you that is working on the filesystem,you have to know
which user is working.
We have to know,who is using the process?
If you want to know,who is using the particular mount you have to click on the fuser.
I am using the fuser with actual mount itself.
[ root@la mnt]# fuser -m /mnt/part2
/mnt/part2:
[ root@la mnt]#
that 1347 is the id,that making the device busy and the c at the end is the which means
someone is hanging out the directory.
[ root@la mnt]# ps aux | grep 1347
root 1347 0.0 0.2 3072 1500 pts/1 S+ xxxxxx bash
root 1424 0.0 0.2 3072 1500 pts/1 S+ xxxxxx bash
1347 right here,is associated with the bash.
If this is the condition in realtime with the user,you have to send him the email to move out
of the directory,so that you can umount the filesystem.
[ root@la mnt]# df -h
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
[ root@la mnt]#
when you do the cat /etc/fstab and you can see the /mnt/part1
but when you do the df –h you cannot see the /mnt/part1
but after doing the mount -a and if you do the
df –h now you can see the /mnt/part1.
Note:
disk mount correctly in the /etc/fstab = mount -a
it mounts your partition,it mounts on boot.
Otherwise,it will give error if one the configuration file is off.
No comments:
Post a Comment