[root@localhost Desktop]# make
make -C /usr/src/kernels/2.6.32-279.el6.i686 / M=/root/Desktop modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-279.el6.i686'
LD /root/Desktop/built-in.o
CC [M] /root/Desktop/ramdisk.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/Desktop/ramdisk.mod.o
LD [M] /root/Desktop/ramdisk.ko.unsigned
NO SIGN [M] /root/Desktop/ramdisk.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.el6.i686'
[root@localhost Desktop]# insmod ramdisk.ko
[root@localhost Desktop]# ls /dev/ramhd*
/dev/ramhda /dev/ramhdb
[root@localhost Desktop]# fdisk /dev/ramhda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x73569d74.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
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): p
Disk /dev/ramhda: 8 MB, 8388608 bytes
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x73569d74
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-1, default 1): 1
Command (m for help): p
Disk /dev/ramhda: 8 MB, 8388608 bytes
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x73569d74
Device Boot Start End Blocks Id System
/dev/ramhda1 1 1 8001 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost Desktop]# mkfs.ext3 /dev/ramhda1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
2000 inodes, 8000 blocks
400 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=8388608
1 block group
8192 blocks per group, 8192 fragments per group
2000 inodes per group
正在写入inode表: 完成
Creating journal (1024 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost Desktop]# mount /dev/ramhda1 /mnt
[root@localhost Desktop]# cd /mnt
[root@localhost mnt]# ll
总用量 12
drwx------. 2 root root 12288 5月 30 15:29 lost+found
[root@localhost mnt]# gedit hello.c
[root@localhost mnt]# gcc -o hello hello.c
[root@localhost mnt]# ./hello
Hello World!
[root@localhost mnt]#