1. 程式人生 > >parted?命令實戰案例

parted?命令實戰案例

parted 實戰案例

========================================================

(1)既適用於gpt格式,又適用於mbr格式。

(2)單個文件在2T以上,需要使用parted來分區。

主要內容:

============================================

一、使用parted 進行分區

二、創建生產上使用的parted分區的步驟

============================================

一、使用parted 進行分

[root@db01 /]# parted /dev/sdd ###使用parted 對/dev/sdd進行分區

GNU Parted 2.1 ### parted的版本

Using /dev/sdd ### parted 執行操作的磁盤

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) p ### 顯示當前磁盤的分區

Model: VMware, VMware Virtual S (scsi) ###磁盤的信息,虛擬的scsi磁盤

Disk /dev/sdd: 1074MB ###磁盤的大小

Sector size (logical/physical): 512B/512B ###扇區大小

Partition Table: msdos ###當前磁盤分區表標簽msdos

Number Start End Size File system Name Flags

(parted) mklabel ###創建磁盤分區標簽

New disk label type? gpt ###設置磁盤分區標簽為gpt

Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to

continue?

Yes/No? y ###繼續

(parted) mkpart oracle 0 -1 ####創建磁盤分區從0開始,-1代表剩余全部。若為數值,如100 表示分區大小100M

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? i ###忽略警告

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number Start End Size File system Name Flags ###新建分區信息

1 17.4kB 1073MB 1073MB oracle

(parted) mkpart ###交互式創建parted分區

Partition name? []? test ###分區名稱

File system type? [ext2]? ext2 ###分區格式

Start? 1

End? 2

Warning: You requested a partition from 1000kB to 2000kB.

The closest location we can manage is 1073MB to 1073MB.

Is this still acceptable to you?

Yes/No? y

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? i

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number Start End Size File system Name Flags

1 17.4kB 1073MB 1073MB oracle

2 1073MB 1073MB 512B test

(parted) rm 2

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number Start End Size File system Name Flags

1 17.4kB 1073MB 1073MB oracle

(parted) q

Information: You may need to update /etc/fstab.

二、創建生產上使用的parted分區的步驟

【適用場景】如果Oracle 數據庫需要添加10T備份空間,使用parted添加

步驟一:指定需要創建parted分解的存儲設備

[root@db01 /]# parted /dev/sdd

GNU Parted 2.1

Using /dev/sdd

Welcome to GNU Parted! Type 'help' to view a list of commands.

步驟二:查看當前parted分區情況

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number Start End Size File system Name Flags

步驟三:創建parted的分區標簽

(parted) mklabel

New disk label type? gpt

Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to

continue?

Yes/No? yes

步驟四: 創建parted的分區

(parted) mkpart oracle 0 -1

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? i

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number Start End Size File system Name Flags

1 17.4kB 1073MB 1073MB oracle

(parted) q

Information: You may need to update /etc/fstab.

步驟五:對parted分區進行格式化

[root@db01 /]# mkfs.ext4 /dev/sdd1

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

65536 inodes, 261895 blocks

13094 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=268435456

8 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@db01 /]#

步驟六:掛載parted分區

[root@db01 /]# mount /dev/sdd1 /alexpeng/

[root@db01 /]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 45G 4.4G 39G 11% /

tmpfs 1004M 0 1004M 0% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/sdb2 79G 184M 75G 1% /oracle

/dev/sdb1 20G 172M 19G 1% /soft

/dev/sdd1 1007M 18M 939M 2% /alexpeng

[root@db01 /]#

[root@db01 /]#

[root@db01 /]# mount

/dev/sda3 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/sdb2 on /oracle type ext4 (rw)

/dev/sdb1 on /soft type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

/dev/sdd1 on /alexpeng type ext4 (rw)

步驟七:設置開啟分區自啟動

[root@db01 /]# vi /etc/fstab ###添加如下信息

/dev/sdd1 /alexpeng ext4 defaults 0 0

[root@db01 /]# umount /alexpeng/

[root@db01 /]# mount /alexpeng/


parted?命令實戰案例