Linux 使用fdisk添加新分区
Linux 添加 分区 fdisk 使用
2023-09-14 08:58:22 时间
[root@DB-ONE-SERVER~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-sda3
30G 2.4G 26G 9% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 4.0G 0 4.0G 0% /dev/shm
You have new mail in /var/spool/mail/root
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 5221 41833260 8e Linux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesnt contain a valid partition table
Disk /dev/dm-0: 32.3 GB, 32346472448 bytes
255 heads, 63 sectors/track, 3932 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesnt contain a valid partition table
Disk /dev/dm-1: 10.4 GB, 10468982784 bytes
255 heads, 63 sectors/track, 1272 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesnt contain a valid partition table
[root@DB-ONE-SERVER~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content wont be recoverable.
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
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 partitions 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): p
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): p
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@DB-ONE-SERVER~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
[root@DB-ONE-SERVER~]# mkfs.ext4 /dev/sdb1
mke4fs 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
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 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, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune4fs -c or -i to override.
/dev/VolGroup00/sda3 / ext3 defaults 1 1
/dev/sdb1 /u02 ext4 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
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 proc defaults 0 0
/dev/VolGroup00/sda4 swap swap defaults 0 0
~
[root@DB-ONE-SERVER~]# cd /
[root@DB-ONE-SERVER/]# mkdir u02
[root@DB-ONE-SERVER/]# mount -a
[root@DB-ONE-SERVER/]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-sda3
30G 2.4G 26G 9% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 4.0G 0 4.0G 0% /dev/shm
/dev/sdb1 20G 172M 19G 1% /u02
[root@DB-ONE-SERVER/]#
下面来看看虚拟上Linux的添加新的逻辑分区的步骤,其实操作是一样的,只是顺带介绍一下虚拟机如何添加硬盘
Disk /dev/sda: 584.6 GB, 584646328320 bytes
255 heads, 63 sectors/track, 71079 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 19441 156151808 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 19441 44937 204796672 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 44937 57685 102398336 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 57685 71080 107595584 5 Extended
Partition 4 does not end on cylinder boundary.
/dev/sda5 57685 70433 102398336 83 Linux
/dev/sda6 70433 70949 4144768 82 Linux swap
/dev/sda7 70949 71080 1052288 83 Linux
Disk /dev/sdb: 146.1 GB, 146156158976 bytes
2 heads, 24 sectors/track, 5947109 cylinders
Units = cylinders of 48 * 512 = 24576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 3 5947064 142729472 83 Linux
[root@oracle_server ~]#
Disk /dev/sda: 584.6 GB, 584646328320 bytes
255 heads, 63 sectors/track, 71079 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 19441 156151808 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 19441 44937 204796672 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 44937 57685 102398336 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 57685 71080 107595584 5 Extended
Partition 4 does not end on cylinder boundary.
/dev/sda5 57685 70433 102398336 83 Linux
/dev/sda6 70433 70949 4144768 82 Linux swap
/dev/sda7 70949 71080 1052288 83 Linux
Disk /dev/sdb: 146.1 GB, 146156158976 bytes
2 heads, 24 sectors/track, 5947109 cylinders
Units = cylinders of 48 * 512 = 24576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 3 5947064 142729472 83 Linux
[root@oracle_server ~]# echo "- - -" /sys/class/scsi_host/host0/scan
[root@oracle_server ~]# fdisk -l
Disk /dev/sda: 584.6 GB, 584646328320 bytes
255 heads, 63 sectors/track, 71079 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 19441 156151808 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 19441 44937 204796672 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 44937 57685 102398336 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 57685 71080 107595584 5 Extended
Partition 4 does not end on cylinder boundary.
/dev/sda5 57685 70433 102398336 83 Linux
/dev/sda6 70433 70949 4144768 82 Linux swap
/dev/sda7 70949 71080 1052288 83 Linux
Disk /dev/sdb: 146.1 GB, 146156158976 bytes
2 heads, 24 sectors/track, 5947109 cylinders
Units = cylinders of 48 * 512 = 24576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 3 5947064 142729472 83 Linux
Disk /dev/sdc: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesnt contain a valid partition table
[root@oracle_server ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content wont be recoverable.
The number of cylinders for this disk is set to 13054.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
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 partitions 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): p
Disk /dev/sdc: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054):
Using default value 13054
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@oracle_server u04]# mkfs.ext3 /dev/sdc1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
13107200 inodes, 26214055 blocks
1310702 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=29360128
800 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@oracle_server ~]$ more /etc/fstab
# This file is edited by fstab-sync - see man fstab-sync for details
LABEL=/1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/u01 /u01 ext3 defaults 1 2
LABEL=/u02 /u02 ext3 defaults 1 2
LABEL=/u03 /u03 ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0
/dev/sdb1 /u03/flash_recovery_area ext3 defaults 1 2
/dev/hda /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
vi
[oracle@get-orasvr02 ~]$ vi /etc/fstab
# This file is edited by fstab-sync - see man fstab-sync for details
LABEL=/1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/u01 /u01 ext3 defaults 1 2
LABEL=/u02 /u02 ext3 defaults 1 2
LABEL=/u03 /u03 ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0
/dev/sdb1 /u03/flash_recovery_area ext3 defaults 1 2
/dev/sdc1 /u04 ext3 defaults 1 2
/dev/hda /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
[root@oracle_server ~]# mkdir /u04
[root@oracle_server ~]# mount -a
[root@oracle_server ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 147G 86G 54G 62% /
/dev/sda7 1012M 34M 927M 4% /tmp
/dev/sda5 97G 73G 19G 80% /u01
/dev/sda3 97G 84G 7.6G 92% /u02
/dev/sda2 193G 133G 51G 73% /u03
/dev/sdb1 134G 74G 54G 59% /u03/flash_recovery_area
/dev/sdc1 99G 93M 94G 1% /u04
10.14 Linux fdisk命令详解:给硬盘分区 我们在安装操作系统的过程中已经对系统硬盘进行了分区,但如果新添加了一块硬盘,想要正常使用,难道需要重新安装操作系统才可以分区吗?
潇湘隐者 网名潇湘隐者/潇湘剑客、英文名Kerry,兴趣广泛,广泛涉猎,个性随意,不善言辞。执意做一名会写代码的DBA,混迹于IT行业
相关文章
- Linux下添加IP地址的命令简介(linux添加ip命令)
- 管理Linux分区:fdisk指令详解(linux命令fdisk)
- Linux 分区管理:快捷有效的软件解决方案(linux分区软件)
- 分区拯救Linux分区:双系统误删恢复之路(双系统误删linux)
- 在Linux上观看视频的最佳网站(linux视频网站)
- 解决Linux分区空间不足问题(linux分区空间不足)
- Linux中符号的含义探究(linux是什么意思)
- Linux安装LZMA压缩程序的指南(linux安装lzma)
- Linux的发展历程:从分支到成功(linux的分支)
- Linux卷分区:开启数据优化之路(linux卷分区)
- 深入探究 Linux 执行路径,解密程序运行机制(linux执行路径)
- 内容Linux下添加文件尾巴的方法(linux文件末尾添加)
- 深度挖掘Linux线程资源(linux线程资源)
- Linux安装过程中的分区技巧(安装linux如何分区)
- 结构Linux内核源码目录:深入解析(linux内核源代码目录)
- Revolutionizing Communication: The Power of Linux Phone Systems(linux电话)
- Linux安装指南:全面了解分区和安装过程(安装linux系统分区)
- 探索深度 | 详解 Linux 安装步骤与技巧(深度linux安装)
- 借助Linux构建可靠的PC集群(pc集群 linux)
- “Linux 分区命令”:快速掌握 Linux 磁盘管理技巧(linux分区命令)
- Linux下查询进程的简便命令(linux查询进程的命令)