Linux 格式化分区 报错Could not stat /dev/sda3 — No such file or directory

执行分区过程如下:
[root@jyrac2 ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 3002.
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)

Command (m for help): p

Disk /dev/sda: 24.6 GB, 24696061952 bytes
255 heads, 63 sectors/track, 3002 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2355 18916506 83 Linux
/dev/sda2 2356 2610 2048287+ 82 Linux swap / Solaris

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 partition’s 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): u
Changing display/entry units to sectors

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First sector (41929650-48234495, default 41929650):
Using default value 41929650
Last sector or +size or +sizeM or +sizeK (41929650-48234495, default 48234495):
Using default value 48234495

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.
Syncing disks.
You have new mail in /var/spool/mail/root

[root@jyrac2 ~]# fdisk -l

Disk /dev/sda: 24.6 GB, 24696061952 bytes
255 heads, 63 sectors/track, 3002 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2355 18916506 83 Linux
/dev/sda2 2356 2610 2048287+ 82 Linux swap / Solaris
/dev/sda3 2611 3003 3152423 83 Linux
新的分区为/dev/sda3

对分区进行格式化:
[root@jyrac2 /]# mkfs.ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
Could not stat /dev/sda3 — No such file or directory

The device apparently does not exist; did you specify it correctly?

解决这个问题可以使用partprobe 命令,partprobe包含在parted的rpm软件包中。partprobe可以修改kernel中分区表,使kernel重新读取分区表。 因此,使用该命令就可以创建分区并且在不重新启动机器的情况下系统能够识别这些分区。
检查是否安装了partprobe软件包
[root@jyrac2 /]# rpm -q parted
parted-1.8.1-23.el5

[root@jyrac2 /]# partprobe
[root@jyrac2 /]# mkfs -t ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
394400 inodes, 788105 blocks
39405 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=809500672
25 block groups
32768 blocks per group, 32768 fragments per group
15776 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
You have new mail in /var/spool/mail/root
格式化分区成功
[root@jyrac2 /]# mkdir /u02
[root@jyrac2 /]# mount /dev/sda3 /u02
[root@jyrac2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 18G 16G 1.5G 92% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sda3 4.0G 237M 3.6G 7% /u02

发表评论

电子邮件地址不会被公开。