新增磁盘分区总体示例
1、新增磁盘分区总体示例1.1 磁盘信息查看1.2 增加新分区 /dev/vda3 ,格式为 LVM1.3 进行新增分区查看1.4 通知内核,重读分区1.5 对新增分区进行文件系统部署1.6 对新增分区进行挂载使用1.7 编辑 /etc/fstab 文件,实现开机自动挂载
2、Ubuntu 系统进行文件系统部署的时候注意事项2.1 报错提示如下2.2 原因是内核未重读分区信息,解决办法如下2.3 正常挂载使用2.4 设置自动挂载
1、新增磁盘分区总体示例
1.1 磁盘信息查看
[root@tangtang tmp
]# fdisk
-l
Disk
/dev
/vda
: 107.4 GB, 107374182400 bytes
, 209715200 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 label type
: dos
Disk identifier
: 0x000ad887
Device Boot Start End Blocks Id System
/dev
/vda1
* 2048 2099199 1048576 83 Linux
/dev
/vda2
2099200 20971519 9436160 8e Linux
LVM
1.2 增加新分区 /dev/vda3 ,格式为 LVM
[root@tangtang tmp
]# fdisk
/dev
/vda
Welcome to
fdisk (util
-linux
2.23.2).
Changes will remain
in memory only
, until you decide to write them
.
Be careful before using the write command
.
Command (m
for help
): n
Partition type
:
p
primary (2 primary
, 0 extended
, 2 free
)
e extended
Select (default p
):
Using
default response p
Partition
number (3,4, default 3):
First
sector (20971520-209715199, default 20971520):
Using
default value
20971520
Last sector
, +sectors or
+size
{K,M,G} (20971520-209715199, default 209715199): +10G
Partition
3 of type Linux and
of size
10 GiB is
set
Command (m
for help
): t
Partition
number (1-3, default 3): 3
Hex
code (type
L to list all codes
): L
8 AIX 4e
QNX4.x
2nd part
8e Linux
LVM df BootIt
Hex
code (type
L to list all codes
): 8e
Changed type
of partition
'Linux' to
'Linux LVM'
Command (m
for help
): w
The partition table has been altered
!
Calling
ioctl() to re
-read partition table
.
WARNING: Re
-reading the partition table failed
with error
16: Device or resource busy
.
The kernel still uses the old table
. The
new table will be used at
the next reboot or after you run
partprobe(8) or
kpartx(8)
Syncing disks
.
1.3 进行新增分区查看
[root@tangtang tmp
]# fdisk
-l
Disk
/dev
/vda
: 107.4 GB, 107374182400 bytes
, 209715200 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 label type
: dos
Disk identifier
: 0x000ad887
Device Boot Start End Blocks Id System
/dev
/vda1
* 2048 2099199 1048576 83 Linux
/dev
/vda2
2099200 20971519 9436160 8e Linux
LVM
/dev
/vda3
20971520 41943039 10485760 8e Linux
LVM
1.4 通知内核,重读分区
[root@tangtang tmp
]# partx
-a
/dev
/vda
partx
: /dev
/vda
: error adding partitions
1-2
[root@tangtang tmp
]# partx
-a
/dev
/vda
partx
: /dev
/vda
: error adding partitions
1-3
1.5 对新增分区进行文件系统部署
[root@tangtang tmp
]# mkfs
.ext4
/dev
/vda3
mke2fs
1.42.9 (28-Dec
-2013)
Filesystem label
=
OS type
: Linux
Block size
=4096 (log
=2)
Fragment size
=4096 (log
=2)
Stride
=0 blocks
, Stripe width
=0 blocks
655360 inodes
, 2621440 blocks
131072 blocks (5.00%) reserved
for the
super user
First data block
=0
Maximum filesystem blocks
=2151677952
80 block groups
32768 blocks per group
, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks
:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables
: done
Writing inode tables
: done
Creating
journal (32768 blocks
): done
Writing superblocks and filesystem accounting information
: done
1.6 对新增分区进行挂载使用
[root@tangtang tmp
]# mount
/dev
/vda3
/tangtang
/
[root@tangtang tmp
]# cd
/tangtang
/
[root@tangtang tangtang
]# ll
total
16
drwx
------ 2 root root
16384 Oct
31 10:51 lost
+found # 显示此目录,说明挂载成功
1.7 编辑 /etc/fstab 文件,实现开机自动挂载
[root@tangtang tangtang
]echo
"/dev/vda3 /tangtang ext4 defaults 0 0" >> /etc
/fstab
2、Ubuntu 系统进行文件系统部署的时候注意事项
2.1 报错提示如下
root@ubuntu
:~# mkfs
.ext4
/dev
/vda3
mke2fs
1.42.13 (17-May
-2015)
The file
/dev
/vda3 does not exist and no size was specified
.
2.2 原因是内核未重读分区信息,解决办法如下
root@ubuntu
:~# partprobe
root@ubuntu
:~# mkfs
.ext4
/dev
/vda3
mke2fs
1.42.13 (17-May
-2015)
Creating filesystem
with 5242880 4k blocks and
1310720 inodes
Filesystem
UUID: f6e580f1
-7ef3
-4508-84c8
-4a44157c2819
Superblock backups stored on blocks
:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables
: done
Writing inode tables
: done
Creating
journal (32768 blocks
): done
Writing superblocks and filesystem accounting information
: done
2.3 正常挂载使用
root@ubuntu
:~# mkdir
/tangtang
root@ubuntu
:~# mount
/dev
/vda3
/tangtang
root@ubuntu
:~# ls
/tangtang
lost
+found
2.4 设置自动挂载
root@ubuntu
:~# echo
"/dev/vda3 /tangtang ext4 defaults 0 0" >> /etc
/fstab
root@ubuntu
:~# tail
-1 /etc
/fstab
/dev
/vda3
/tangtang ext4 defaults
0 0