Add and Mount logical partitions in linux (manual and automatic)

Source: Internet
Author: User
1. view the new disk [root @ brief top61desktop] fdisk-culdevsdcDiskde I. view the new disk
[Root @ mongotop61 Desktop] # fdisk-cul/dev/sdc

Disk/dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x00000000
2. add logical partitions
[Root @ mongotop61 Desktop] # fdisk-cu/dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x740491c5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)


Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
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)


Command (m for help): n
Command action
E extended
P primary partition (1-4)
E ---------------> select extended partition
Partition number (1-4): 2
First sector (2048-41943039, default 2048 ):
Using default value 2048
Last sector, + sectors or + size {K, M, G} (2048-41943039, default 41943039): 10G
Value out of range.
Last sector, + sectors or + size {K, M, G} (2048-41943039, default 41943039): + 10G


Command (m for help): N
Command action
L logical (5 or over)
P primary partition (1-4)
L -----------------> select logical partition
First sector (4096-20973567, default 4096 ):
Using default value 4096
Last sector, + sectors or + size {K, M, G} (4096-20973567, default 20973567): + 5G


Command (m for help): N
Command action
L logical (5 or over)
P primary partition (1-4)
L -------------------> select logical partition
First sector (10491904-20973567, default 10491904 ):
Using default value 10491904
Last sector, + sectors or + size {K, M, G} (10491904-20973567, default 20973567): + 5G
Value out of range.
Last sector, + sectors or + size {K, M, G} (10491904-20973567, default 20973567 ):
Using default value 20973567


Command (m for help): P ---------------> print the partition list


Disk/dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x740491c5


Device Boot Start End Blocks Id System
/Dev/sdc2 2048 20973567 10485760 5 Extended
/Dev/sdc5 4096 10489855 5242880 83 Linux
/Dev/sdc6 10491904 20973566 5240831 + 83 Linux
Automatically named Logical Partition: sdc5 sdc6
Command (m for help): w ------------------> save and exit
The partition table has been altered!


Calling ioctl () to re-read partition table.
Syncing disks.
[Root @ mongotop61 Desktop] # part
Parted partprobe partx
[Root @ mongotop61 Desktop] # partx-a/dev/sdc
BLKPG: Device or resource busy
Error adding partition 2
BLKPG: Device or resource busy
Error adding partition 5
BLKPG: Device or resource busy
Error adding partition 6
3. View New partitions
[Root @ mongotop61 Desktop] # fdisk-cu/dev/sdc


Command (m for help): p


Disk/dev/sdc: 21.5 GB, 21474836480 bytes
139 heads, 49 sectors/track, 6158 cylinders, total 41943040 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x740491c5


Device Boot Start End Blocks Id System
/Dev/sdc2 2048 20973567 10485760 5 Extended
/Dev/sdc5 4096 10489855 5242880 83 Linux
/Dev/sdc6 10491904 20973566 5240831 + 83 Linux


Command (m for help): q
4. Format partitions
1sdc5
[Root @ shorttop61 Desktop] # mkfs. ext4/dev/sdc5
Mke2fs 1.41.12 (17-May-2010)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
Stride = 0 blocks, Stripe width = 0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736


Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.
2sdc6
[Root @ shorttop61 Desktop] # mkfs. ext4/dev/sdc6
Mke2fs 1.41.12 (17-May-2010)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
Stride = 0 blocks, Stripe width = 0 blocks
327680 inodes, 1310207 blocks
65510 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736


Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.
5. create a Mount Directory
[Root @ mongotop61 Desktop] # cd/mnt/
[Root @ shorttop61 mnt] # ls
Hgfs
[Root @ shorttop61 mnt] # mkdir sdc {5, 6}
[Root @ shorttop61 mnt] # ls
Hgfs sdc5 sdc6
[Root @ shorttop61 mnt] # pwd
/Mnt
6. automatically mount sdc5 and sdc6 to/mnt/sdc5 and/mnt/sdc6 respectively.
[Root @ shorttop61 mnt] # mount/dev/sdc5/mnt/sdc5
[Root @ shorttop61 mnt] # mount/dev/sdc6/mnt/sdc6
7. check whether the mounting is successful
[Root @ override top61 mnt] # mount
/Dev/mapper/vol0-root on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw, rootcontext = "system_u: object_r: tmpfs_t: s0 ")
/Dev/sda1 on/boot type ext4 (rw)
/Dev/mapper/vol0-home on/home type ext4 (rw)
/Dev/sdb5 on/tmp/sdb5 type ext4 (rw)
/Dev/sdb6 on/tmp/sdb6 type ext4 (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
Vmware-vmblock on/var/run/vmblock-fuse type fuse. vmware-vmblock (rw, nosuid, nodev, default_permissions, allow_other)
Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
Gvfs-fuse-daemon on/root/. gvfs type fuse. gvfs-fuse-daemon (rw, nosuid, nodev)
/Dev/sdc5 on/mnt/sdc5 type ext4 (rw)
/Dev/sdc6 on/mnt/sdc6 type ext4 (rw)
9. uninstall sdc5 sdc6
[Root @ shorttop61 mnt] # umount/dev/sdc5
[Root @ shorttop61 mnt] # umount/dev/sdc6
[Root @ override top61 mnt] # mount
/Dev/mapper/vol0-root on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw, rootcontext = "system_u: object_r: tmpfs_t: s0 ")
/Dev/sda1 on/boot type ext4 (rw)
/Dev/mapper/vol0-home on/home type ext4 (rw)
/Dev/sdb5 on/tmp/sdb5 type ext4 (rw)
/Dev/sdb6 on/tmp/sdb6 type ext4 (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
Vmware-vmblock on/var/run/vmblock-fuse type fuse. vmware-vmblock (rw, nosuid, nodev, default_permissions, allow_other)
Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
Gvfs-fuse-daemon on/root/. gvfs type fuse. gvfs-fuse-daemon (rw, nosuid, nodev)
10. manual mounting
1. view the UUID of sdb5
[Root @ shorttop61 mnt] # blkid/dev/sdb5
2. manually Mount sdb5 and sdb6
[Root @ shorttop61 mnt] # cd/etc
[Root @ shorttop61 etc] # vi fstab


#
#/Etc/fstab
# Created by anaconda on Fri Apr 11 00:49:26 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
/Dev/mapper/vol0-root/ext4 ULTS 1 1
UUID = 9425a628-e49f-4675-abf4-b0fe76b38fbc/boot ext4 ULTS 1 2
/Dev/mapper/vol0-home/home ext4 defaults 1 2
UUID = f3d4a81c-f2d6-48d8-be1a-35647cd74615 swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
UUID = dfa6e086-e5be-4856-9e8d-9565d52b82e6/mnt/sdc5 ext4 defaults 0 0
/Dev/sdc6/mnt/sdc6ext4 defaults0 0
By using the partition name and UUID
11. View mounting results
[Root @ override top61 etc] # mount-a ----------------> refresh the mount
[Root @ override top61 etc] # mount
/Dev/mapper/vol0-root on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw, rootcontext = "system_u: object_r: tmpfs_t: s0 ")
/Dev/sda1 on/boot type ext4 (rw)
/Dev/mapper/vol0-home on/home type ext4 (rw)
/Dev/sdb5 on/tmp/sdb5 type ext4 (rw)
/Dev/sdb6 on/tmp/sdb6 type ext4 (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
Vmware-vmblock on/var/run/vmblock-fuse type fuse. vmware-vmblock (rw, nosuid, nodev, default_permissions, allow_other)
Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
Gvfs-fuse-daemon on/root/. gvfs type fuse. gvfs-fuse-daemon (rw, nosuid, nodev)
/Dev/sdc5 on/mnt/sdc5 type ext4 (rw)
/Dev/sdc6 on/mnt/sdc6 type ext4 (rw)
[Root @ shorttop61 etc] #
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.