Creating EXT2 USB Flash Drive from Windows

8 篇文章 0 订阅
1 篇文章 0 订阅
I did an experiment to create an EXT2 file system on my USB Flash Drive in Windows Vista. Because I have Windows Vista installed and I don't want to repartition the hard disk drive to install Linux individually, I had to use some other method. I don't have any tool to create an EXT2 FS directly from Windows.

An idea popped up to my mind. Virtual Box supports virtualizing USB devices for the guest operating system. Why not use Virtual Box to run a version of Linux to make that file system?

So I began working. However the first time after I installed Slackware 12.0 I failed to find any USB thumb (flash) drive in the Slackware installation. I clicked the Virtual Box menu, "USB Devices" and then the USB thumb drive, and then searched for /dev/sd* inside Slackware but nothing was returned.

Again, without turning off the virtual machine, I first clicked the "Safely Remove Hardware" icon in the Windows Notification Icon Area (in the task bar) and then clicked the menu item of the USB thumb drive to safely remove it. I guess this may help Virtual Box to grab that device safely. Again I tried the Virtual Box, and Slackware, but still didn't find that device.

Later, I shut down the VM. I opened the Virtual Box settings for the Slackware VM, and found an option to automatically filter USB devices. I then used this feature to automatically filter the USB thumb drive.

After that, I closed Virtual Box totally, and physically unplugged the USB thumb drive. Then I plugged it in again, without doing any action of safe removal from Windows.

Then I started Virtual Box, and ran Slackware inside Virtual Box again. It booted. Afterwards, I consulted an article in Linux Questions Wiki (http://wiki.linuxquestions.org/wiki/USB_Flash_drive) and found that I can use the lsusb command to show the usb devices (also "modprobe usb-storage" to see if USB storage support exists in the kernel). By comparing the Device ID listed in "lsusb" and that of my USB thumb drive (in the "USB Devices" menu of Virtual Box, displayed as a tooltip when mouse is over it), I confirmed it is the USB thumb drive. Then I called "ls -l --color /dev/sd*" and found the sda and sda1 devices.

Because I didn't succeed in using cfdisk to examine /dev/sda, I guess it may not be the "physical hard disk", or may just be a partition only. So I want to examine whether it has an MBR. To do this, I used:

dd if=/dev/sda of=sda_sect0.dat bs=512 count=1

Then I used "od" to examine it:

od -t x1 --address-radix=x sda_sect0.dat

And I looked at the address 0x1BE:

00 (00 01 01) 0c (43 c4 20) (80 1f 00 00) (80 80 dc 01)

It looks like the data is a partition table entry. So probably it is an MBR rather than a boot sector of a parition. Then I examined the first sector of sda1, and that looked like a boot sector. I also ran "fdisk" instead of "cfdisk" on sda, and it did show me the partition data.

Then, I ran the command to make the EXT2 FS:

mkfs.ext2 -c -c -L KING4 -v /dev/sda1

The two "-c" switches tell mkfs.ext2 to do write-check the media to see if it's free of bad blocks. This rarely needs to be done. The reason I added it is to look at how it works. It took about 12 hours to test the 16GB UFD at about 4MB/s and 8 passes ((0x55/0xaa/0x00/0xff) * (write/read)), so you'd better not do it :-)

Finally, the file system is made, successfully. After that, see my follow-up article.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值