parted partition and mount operations parted and non-interactive and non-interactive partition and mount operations

                                             parted partition and mount and non-interactive operation

 

Case 1: Create a new primary partition

Interactive parted partition command

------------------------------------------------------------------------------------------------------------------------------------

1, the original disk partition deleted:

    Enter: #parted / dev / sdb

    View: (parted) p

    Delete: (parted) rm 1

              (parted)rm  2

 2, the disk format become gpt format (since parted can only operate for gpt disk format)

   Conversion: (parted) mklabel gpt

   Partition: (parted) mkpart primary 1 500 (a first sub-primary partition 500MB)

   Partition: (parted) mkpart primary 501 1000 (points second primary partition 500MB)

   Zoning: (parted) mkpart logical 1001 2000 (third division logical partitions 1000MB) (parted logical partition without first extended partition points, directly in one step)

   View: (parted) p

   Exit: (parted) quit (parted partition saved automatically, without having to manually save)

3, has good points formatting region

   # mkfs -t ext4 /dev/sdb1

4, Mount

  # mount  /dev/sdb1 /mnt

5, boot automatically mount:

 # echo  “/dev/sdb1 /mnt ext4 defaults 0 0”  >>/etc/fstab

 

 Non-interactive parted partition command

------------------------------------------------------------------------------------------------------------------------------------

[root@localhost 桌面]# parted /dev/sdb mklabel gpt 

 

[root@localhost 桌面]# parted /dev/sdb mkpart primary 1 500
[root@localhost 桌面]# parted /dev/sdb mkpart primary 501 1000 

[root@localhost 桌面]# parted /dev/sdb mkpart logical 1001 2000 

[Root @ localhost Desktop] # parted / dev / sdb p

...

Number    Start    End         Size        File       system Name      标志
  1       1049kB   500MB     499MB    primary
  2        501MB   1000MB   499MB    primary
  3      1001MB   2000MB   998MB    logical

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb1

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb2

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb3

[root @ localhost Desktop] # Mount / dev / sdb1 / A
[root @ localhost Desktop] # Mount / dev / sdb2 / B
[root @ localhost Desktop] # Mount / dev / sdb3 / C
[root @ localhost Desktop] # touch } /a/a{1..100
[root @ localhost Desktop] # Touch /b/b{1..100}
[root @ localhost Desktop] # Touch /c/c{1..100}
[root @ localhost Desktop] # LS / A
A1 ..... A16 A23 A30 A38 A45 A52 A67 A74 A81 A89 A96 A6

[the root @ localhost Desktop] # LS / B
B1 .... B16 B23 B30 B38 B45 B52 B67 B74 B81 B89 B6 B96

[root @ localhost Desktop] # LS / c
c1 ..... c16 C23 C30 C38 C45 C52 C67 C74 C81 C89 C96 c6

[root@localhost 桌面]# echo "/dev/sdb1 /a ext4 defaults 0 0" >>/etc/fstab
[root@localhost 桌面]# echo "/dev/sdb2 /b ext4 defaults 0 0" >>/etc/fstab
[root@localhost 桌面]# echo "/dev/sdb3 /c ext4 defaults 0 0" >>/etc/fstab

 


Case 2: Create a new logical volume

2.1 problem

This embodiment follows the one day before the required case using partition / dev / vdb1 build LVM storage requirements as follows:

  1. Create a volume group named systemvg of
  2. Create a file called vo in this volume group logical volume, the size of 180MiB
  3. The logical volume is formatted EXT4 file system vo
  4. Mount a logical volume vo / vo directory, and create a test file in this directory votest.txt, says "I AM KING."

2.2 program

LVM tools to create basic usage:

  1. vgcreate vgname physical device ..  ..
  2. the lvcreate   - L Size   - n-logical name of the volume group name

Step 2.3

This case needs to be achieved in the following steps.

Step one: create a volume group

1) of the new volume group named systemvg

  1. [root@server0 ~]# vgcreate  systemvg  /dev/vdb1
  2. Physical volume "/dev/vdb1" successfully created
  3. Volume group "systemvg" successfully created

2) confirm the results

  1. [root@server0 ~]# vgscan
  2. Reading all physical volumes.  This may take a while...
  3. Found volume group "systemvg" using metadata type lvm2

Step two: create a logical volume

1) Create a logical volume called vo

  1. [root@server0 ~]# lvcreate  -L  180MiB  -n  vo  systemvg
  2. Logical volume "vo" created

2) confirm the results

  1. [root@server0 ~]# lvscan
  2. ACTIVE            '/dev/systemvg/vo' [180.00 MiB] inherit

Step Three: To Mount formatting and

1) to format the logical volume / dev / systemvg / vo

  1. [root@server0 ~]# mkfs.ext4  /dev/systemvg/vo
  2. .. ..
  3. Allocating group tables: done
  4. Writing inode tables: done
  5. Creating journal (4096 blocks): done
  6. Writing superblocks and filesystem accounting information: done

2) to mount the logical volume / dev / systemvg / vo

  1. [ Root @ server0  ~] # mkdir   / VO // create the mount point
  2. [ The root server0 @  ~] # Mount   / dev / systemvg / VO   / VO // mount
  3. [ Root @ server0  ~] # df   - hT   / VO /                          // test results
  4. Filesystem              Type  Size  Used Avail Use% Mounted on
  5. /dev/mapper/systemvg-vo ext4  171M  1.6M  157M   1% /vo

3) access to the logical volume / dev / systemvg / vo

  1. [root@server0 ~]# cat  /vo/votest.txt
  2. I AM KING.

 

Case 1: Create a new primary partition

Interactive parted partition command

------------------------------------------------------------------------------------------------------------------------------------

1, the original disk partition deleted:

    Enter: #parted / dev / sdb

    View: (parted) p

    Delete: (parted) rm 1

              (parted)rm  2

 2, the disk format become gpt format (since parted can only operate for gpt disk format)

   Conversion: (parted) mklabel gpt

   Partition: (parted) mkpart primary 1 500 (a first sub-primary partition 500MB)

   Partition: (parted) mkpart primary 501 1000 (points second primary partition 500MB)

   Zoning: (parted) mkpart logical 1001 2000 (third division logical partitions 1000MB) (parted logical partition without first extended partition points, directly in one step)

   View: (parted) p

   Exit: (parted) quit (parted partition saved automatically, without having to manually save)

3, has good points formatting region

   # mkfs -t ext4 /dev/sdb1

4, Mount

  # mount  /dev/sdb1 /mnt

5, boot automatically mount:

 # echo  “/dev/sdb1 /mnt ext4 defaults 0 0”  >>/etc/fstab

 

 Non-interactive parted partition command

------------------------------------------------------------------------------------------------------------------------------------

[root@localhost 桌面]# parted /dev/sdb mklabel gpt 

 

[root@localhost 桌面]# parted /dev/sdb mkpart primary 1 500
[root@localhost 桌面]# parted /dev/sdb mkpart primary 501 1000 

[root@localhost 桌面]# parted /dev/sdb mkpart logical 1001 2000 

[Root @ localhost Desktop] # parted / dev / sdb p

...

Number    Start    End         Size        File       system Name      标志
  1       1049kB   500MB     499MB    primary
  2        501MB   1000MB   499MB    primary
  3      1001MB   2000MB   998MB    logical

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb1

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb2

[Root @ localhost Desktop] # mkfs -t ext4 / dev / sdb3

[root @ localhost Desktop] # Mount / dev / sdb1 / A
[root @ localhost Desktop] # Mount / dev / sdb2 / B
[root @ localhost Desktop] # Mount / dev / sdb3 / C
[root @ localhost Desktop] # touch } /a/a{1..100
[root @ localhost Desktop] # Touch /b/b{1..100}
[root @ localhost Desktop] # Touch /c/c{1..100}
[root @ localhost Desktop] # LS / A
A1 ..... A16 A23 A30 A38 A45 A52 A67 A74 A81 A89 A96 A6

[the root @ localhost Desktop] # LS / B
B1 .... B16 B23 B30 B38 B45 B52 B67 B74 B81 B89 B6 B96

[root @ localhost Desktop] # LS / c
c1 ..... c16 C23 C30 C38 C45 C52 C67 C74 C81 C89 C96 c6

[root@localhost 桌面]# echo "/dev/sdb1 /a ext4 defaults 0 0" >>/etc/fstab
[root@localhost 桌面]# echo "/dev/sdb2 /b ext4 defaults 0 0" >>/etc/fstab
[root@localhost 桌面]# echo "/dev/sdb3 /c ext4 defaults 0 0" >>/etc/fstab

 


Case 2: Create a new logical volume

2.1 problem

This embodiment follows the one day before the required case using partition / dev / vdb1 build LVM storage requirements as follows:

  1. Create a volume group named systemvg of
  2. Create a file called vo in this volume group logical volume, the size of 180MiB
  3. The logical volume is formatted EXT4 file system vo
  4. Mount a logical volume vo / vo directory, and create a test file in this directory votest.txt, says "I AM KING."

2.2 program

LVM tools to create basic usage:

  1. vgcreate vgname physical device ..  ..
  2. the lvcreate   - L Size   - n-logical name of the volume group name

Step 2.3

This case needs to be achieved in the following steps.

Step one: create a volume group

1) of the new volume group named systemvg

  1. [root@server0 ~]# vgcreate  systemvg  /dev/vdb1
  2. Physical volume "/dev/vdb1" successfully created
  3. Volume group "systemvg" successfully created

2) confirm the results

  1. [root@server0 ~]# vgscan
  2. Reading all physical volumes.  This may take a while...
  3. Found volume group "systemvg" using metadata type lvm2

Step two: create a logical volume

1) Create a logical volume called vo

  1. [root@server0 ~]# lvcreate  -L  180MiB  -n  vo  systemvg
  2. Logical volume "vo" created

2) confirm the results

  1. [root@server0 ~]# lvscan
  2. ACTIVE            '/dev/systemvg/vo' [180.00 MiB] inherit

Step Three: To Mount formatting and

1) to format the logical volume / dev / systemvg / vo

  1. [root@server0 ~]# mkfs.ext4  /dev/systemvg/vo
  2. .. ..
  3. Allocating group tables: done
  4. Writing inode tables: done
  5. Creating journal (4096 blocks): done
  6. Writing superblocks and filesystem accounting information: done

2) to mount the logical volume / dev / systemvg / vo

  1. [ Root @ server0  ~] # mkdir   / VO // create the mount point
  2. [ The root server0 @  ~] # Mount   / dev / systemvg / VO   / VO // mount
  3. [ Root @ server0  ~] # df   - hT   / VO /                          // test results
  4. Filesystem              Type  Size  Used Avail Use% Mounted on
  5. /dev/mapper/systemvg-vo ext4  171M  1.6M  157M   1% /vo

3) access to the logical volume / dev / systemvg / vo

  1. [root@server0 ~]# cat  /vo/votest.txt
  2. I AM KING.

Guess you like

Origin www.cnblogs.com/qingbai/p/11988374.html