Ubuntu 18.04使用GPT分区并挂载硬盘
进行sudo fdisk -l
查看机器上都插了哪些安装盘,看到/dev/sda
,并且没有进行分区。
这个时候是没有挂载的,运行如下命令:
sudo parted /dev/sda
#进入partedmklabel gpt
#将磁盘设置为gpt
格式,mkpart logical 0 -1
#将磁盘所有的容量设置为gpt
格式print
#查看分区结果quit
#退出
root@XXX:~# sudo parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you
want to continue?
Yes/No? no
(parted) mkpart logical 0 -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ingnore
parted: invalid token: ingnore
Ignore/Cancel? ignore
(parted) print
Model: Phi H1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1000GB 1000GB logical
(parted) quit
这个时候应该是默认进行分了一个/dev/sda1
这个分区
- 运行
sudo mkfs.ext4 -F /dev/sda1
将刚刚分出来的sda1
格式化为ext4
的格式,然后就可以设置开机自动挂载了。
root@XXX:~# sudo mkfs.ext4 -F /dev/sda1
mke2fs 1.44.1 (24-Mar-2018)
Suggestion: Use Linux kernel >= 3.18 for improved stability of the metadata and journal checksum features.
Creating filesystem with 244190397 4k blocks and 61054976 inodes
Filesystem UUID: d268738c-949e-45a3-9170-1390c49fcac1
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
设置挂载点
sudo mkdir /home/phd1
phd1
为新文件名,文件名可自定义
执行 sudo nano /etc/fstab
在文件末尾添加
/dev/sda1 /home/phd1 ext4 defaults 0 0
使用sudo mount -a
即可进行重新挂载