简体   繁体   中英

NFS mount point as a disk device linux

  1. A remote NAS server provides an NFS share (/myShare) to a linux client machine
  2. From the linux client, I mounted the NFS share ( Eg./mnt/myShare )

My question is, Is it possible to convert this /mnt/myShare as a disk device (eg./dev/mydevice)

I would like to use this disk as a physical disk itself to a container to store its data.

Can device mapper be of help here.. Any leads would be of help here

--kk

Is it possible to convert this /mnt/myShare as a disk device (eg./dev/mydevice)

The answer is yes and no. Yes, because you can mount everything anywhere, ie you can:

mount -t nfs nas:/myShare /dev/mydevice

(provided that the directory /dev/mydevice exists).

NO, because a disk is a file under /dev, which basically exposes a set of sectors (or clusters) - other OS components use that to present a file system, which then is mounted somewhere else.

You, instead, have already a file which represents a file system. You can mount that file system wherever you want. 99% of your OS, and your programs, will not care about.

But your share is not a disk, because it is something (a directory part of a file system) exported by another machine. And this difference cannot be circumvented. I think you can live with this without problems but, if your question is literally correct, then no: an exported share is not a disk.

If you want to use the raw hard drive, then you don't need a filesystem. Perhaps your NAS server can be configured to export its storage as an iSCSI target .

NFS itself doesn't implement storage as block device.

But what you can do is the following:

  1. Mount /myShare onto /mnt/myShare .
  2. Create a file the size of all of myShare . For example, if myShare is 3TB in size, do truncate -s 3T /mnt/myShare/loop.img . (at this point, if you wanted a filesystem, you could have done mkfs -t ext4 /mnt/myShare/loop.img ).
  3. Set up the file as a loop device: sudo losetup /dev/loop7 /mnt/myShare/loop.img
  4. You now have a 3TB block device on /dev/loop7 , which you can see in the output of grep loop7 /proc/partitions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM