host > sudo mke2fs -vm0 -b 1024 /dev/ram0 65536 // sudo mke2fs -t ext4 -vm0 -b 4096 /dev/ram0 32768
host > sudo tune2fs -c 0 /dev/ram0
host > sudo dd if=/dev/ram0 bs=1k count=65536 | gzip -v9 > ramdisk.gz
========================================================================
host > mkdir mnt
host > gunzip ramdisk.gz
host > sudo mount -o loop ramdisk mnt/
host > ... copy stuff you want to have in ramdisk to mnt...
host > sudo umount mnt
host > gzip -v9 ramdisk
========================================================================
========================================================================
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=4
CONFIG_BLK_DEV_RAM_SIZE=65536
========================================================================
========================================================================
========================================================================
{
int r = sys_read(crd_infd, buf, len);
printk("%s: initrd len 0x%x, buf %p, return %d\n", __func__, len, buf, r);
if (r < 0)
printk(KERN_ERR "RAMDISK: error while reading compressed data");
else if (r == 0)
printk(KERN_ERR "RAMDISK: EOF while reading compressed data");
return r;
}
static int __init compr_flush(void *window, unsigned int outcnt)
{
static unsigned long total_written;
int written = sys_write(crd_outfd, window, outcnt);
total_written += written;
if (written != outcnt) {
if (decompress_error == 0)
printk(KERN_ERR
"RAMDISK: incomplete write (%d != %d) total written %lu\n",
written, outcnt, total_written);
decompress_error = 1;
total_written = 0;
return -1;
}
return outcnt;
}
========================================================================
## initrd_high = 0xffffffff, copy_to_ram = 1
Loading Ramdisk to 867a8000, end 871ef24d ... OK
ramdisk load start = 0x867a8000, ramdisk load end = 0x871ef24d
[ 0.467441] populate_rootfs: initrd_start 0xc67a8000 initrd_end 0xc71ef24d
No comments:
Post a Comment