天天看点

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

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

/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

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.

格式化分区成功

[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

继续阅读