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
    评论
### 回答1: 这个警告是在使用NumPy创建多维数组时出现的。其中,输入的嵌套序列(nested sequences)的形状可能不一致,因此会被称为“ragged”,即不整齐的序列。 在 NumPy 中,数组是由相同大小的元素组成的,因此当创建一个由 ragged sequences 组成的数组时,NumPy 需要将其转换为一个整齐的数组。这个转换过程可能会导致数据的丢失或不准确。 因此,这个警告提示你可能需要检查你的输入数据是否正确,或者尝试使用其他方法来创建数组,以避免数据的不准确或丢失。 ### 回答2: “visibledeprecationwarning: creating an ndarray from ragged nested sequences”是一种警告提示信息,通常出现在使用NumPy库中的ndarray对象时。它的意思是在将嵌套序列转换为ndarray时,会出现不均匀的嵌套序列,即长度不相等的嵌套列表或元组等。 这个警告意味着代码中存在潜在的问题,因为嵌套序列的长度不相等,可能会导致错误或崩溃。 虽然ndarray对象可以处理大小相等的嵌套序列,但是在尝试转换不均匀嵌套序列时会发出弃用警告,以提醒开发者尽快进行代码修复。 因此,如果实现代码正确而且没有错误发生,不建议忽略这个警告。开发者可以通过修改嵌套序列的长度来解决此问题。在一些情况下,可以使用pad_sequences方法来将长度不均匀的序列对齐。有时也可以通过动态调整嵌套序列的长度来避免警告。 总而言之,在使用ndarray对象时,如果出现“visibledeprecationwarning: creating an ndarray from ragged nested sequences”这个警告,开发者需要仔细查看代码并调整数据形式以确保实现代码的正确性。 ### 回答3: 在Python编程中,当我们创建一个数组(ndarray)的时候,可能会在输出中看到一个警告信息:“visibledeprecationwarning: creating an ndarray from ragged nested sequences”,这是什么意思呢? 首先,我们需要了解什么是ndarray。ndarray是NumPy库中的数据类型,它是一个多维数组对象,每个元素都是相同类型的数据。ndarray在科学计算中非常常用,因为它能够高效地处理大规模数据,同时提供了许多数学函数和操作。 当我们创建一个ndarray的时候,我们通常会使用一个列表(list)或者其他序列作为输入参数,例如: import numpy as np a = np.array([1, 2, 3]) 这样就创建了一个包含1、2、3三个元素的一维数组。但是,警告信息中多出了“ragged nested sequences”这个词,它是什么意思呢? ragged nested sequences是指嵌套列表或者元组中的不规则数据结构。例如: import numpy as np b = np.array([[1, 2], [3, 4, 5]]) 这里创建了一个二维数组,第一行有两个元素,第二行有三个元素。这就是一个不规则的嵌套列表,被称为ragged nested sequences。 在早期的NumPy版本中,ndarray可以从ragged nested sequences中创建,但是这种方式很容易出错,而且效率不高。因此,在较新的版本中,这种创建方式已被弃用(deprecated),同时也给出了一个警告信息。 因此,当我们看到这个警告信息的时候,应该尽量避免使用ragged nested sequences,而是使用规则的列表或者其他序列来创建ndarray。这样可以避免不必要的错误,并且提高代码的效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值