Ubuntu :: Code To Access Hard Disk Sectors (LoopBack Device)

Jan 26, 2011

I'm kind of new to programming in Linux & c/c++. I'm currently writing a FileManager using Ubuntu Linux(10.10) for Learning Purposes. I've got started on this project by creating a loopback device to be used as my virtual hard disk. After creating the loop back hard disk and mounting it has the following configuration.

Code: $> sudo fdisk -l /dev/loop0
Disk /dev/loop0: 10 MB, 10977280 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: 0x00000000

Disk /dev/loop0 doesn't contain a valid partition table Now what I want to do is develop a c++ program to read & write files to this loop back device,which I'm using to simulate an actual hard disk,at the blocks & sectors level. So far I've come up with the following code. But I'm still unable to read files from the hard disk one block at a time.

Code: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
char block[512]; int length=0;
cout<<"Implementation of the File Handler Read Method..."<<endl;
FILE *f = fopen("/dev/loop0", "r");
if(f == NULL) {
cout<<"Error In Opening the HardDisk File Retuning Error..."<<endl; return -1; }
//Read One Block of Data to Buffer length = fread(block, 1, sizeof(block), f);
/* Do something with the data */ cout<<"Length : "<<length<<endl;
return 0; }

When I run this Program All what I get is the message for NULL. "Error In Opening the HardDisk File Retuning Error...". So I could open the loopback device as a file an access it at the sectors & block level.

View 1 Replies


Hardware :: Scan And Fix Bad Sectors On Hard Disk Without Damaging Data?

Dec 19, 2010

How to scan and fix Bad Sectors on Hard Disk without damaging data?

View 5 Replies View Related

General :: Gnome Disk Utility Warned That Hard Drive Had Numerous Bad Sectors / Fix It?

Feb 21, 2010

I recently tried Fedora on my laptop (previously Debian; I was bored one day) and gnome-disk-utility (palimpsest) warned me that my hard drive had numerous bad sectors. I re-installed Debian to find that this software was installed before so why had it not warned me?

When I load the disk utility, it says SMART is not available. I've got smartmontools installed, I can run a self-test with smartctl but I don't think this shows bad sectors. I've tried starting smartd on startup but the disk utility never changes from "SMART is not available". It is possible for it to work with this hardware as it works in Fedora on this laptop; any ideas?

View 3 Replies View Related

Fedora :: Device Hasn't Booted From Hard Disk?

Jul 26, 2009

2 days ago i have tried to install fedora 11 ...but after i did achieved installation successfully ...and rebooted system ,the device hasn't booted from hard disk ,alternatively it has booted from the network (Broadcom)- the third booting choice in bios - . i have tried three different DVDs ....but no thing changes ...!

View 1 Replies View Related

General :: 1TB Hard Disk Partition - Device Not Created

Apr 30, 2010

I have installed 1tb hard drive and would like to partition as follows:

1) / - 20g
2) /swap - 6G
3) /photos /150g
4) /videos /500g
5) /audio /300g

After 2-3 partition an extended partition automatically created in which I am not able to create specified capacity i.e., say I want 150g of /photos partition, the /videos partition is automatically reduced and a free space at the end appears. Some free space is always there which i am not able to understand. Nevertheless i clicked to create, but I get an error viz. 'device not created'.

View 7 Replies View Related

Hardware :: SCSI Hard Disk Device Node Creation

Mar 26, 2010

I am developing for a Linux based device for which the HOT PLUG option is deactivated. As part of optimizing the code, we also don't want to create device files for unused devices. We understand that both USB attached and fixec SCSI hard disks would create device files like /dev/sda,/dev/sda1 /dev/sdb, /dev/sdb1 etc. Is this understanding correct?

In the case of USB attached SCSI devices, would driver create this device file entry? How is it created? Can somebody please tell me how it is being created automatically. In case I attach a fixed SCSI hard disk before boot up(and create device file /dev/sda1), would USB SCSI device driver create device files starting from /dev/sdb, automatically.

View 4 Replies View Related

Hardware :: Cannot Partition Hard Disk - No Valid Device Found

Mar 25, 2010

I have installed vmware in windows server 2003 enterprise edition. When I installed I changed the default installation folder from c: drive to i: drive, as I do not have space in c: drive. After I captured red hat linux cd in vmware and reached partitioning section and continued I got a message like "an error has occured no valid devices were find on which to create new file systems, please check the hardware for the cause of the problem". The machine is IBM server....

View 1 Replies View Related

Ubuntu :: Mount Loopback Device As Root

Jun 23, 2011

I am trying to expand my Ubuntu partition into my Windows 7 C: drive, but the win7 partioner will not let me shrink it because of immovable files. Is there anyway for me to but an loopback device in the windows partion, and have Ubuntu boot with that as the root device?

View 1 Replies View Related

Ubuntu :: How To Fix A Hard Drive With Bad Sectors

Jan 20, 2010

I recently got a bad virus that wouldnt let me reinstall Windows so I figured I would install Ubuntu and give it a go, but now it says my hard drive has "many bad sectors" a quick Google search shows many ways to fix this in Windows, but how do I do it in Ubuntu?Easily since Im just getting the hang of things.

View 8 Replies View Related

Fedora :: WebCamStudio- No Loopback Device

Jul 21, 2010

I have extracted the WebCamStudio java application into a folder in my Fedora 13 x86_64 installation. I can run WebCamStudio with the command java -jar "WebcamStudio.jar".

I can successfully select sources and view preview etc. However, the bottom status line permanently states "no output". There is no vloopback device to select in Cheese, camstream, Skype, AMsn etc. Does anyone know how I can get the loopback device to work?

I have added my username to the group "video"

I only have /dev/video0 - should there be another module for the loopback device?

WebcamStudio 0.55a

View 3 Replies View Related

Networking :: Pseudodevice And Loopback Device ?

Nov 22, 2010

The concepts of pseudodevice and loopback device ?

View 1 Replies View Related

General :: Broken Loopback Device ?

May 26, 2010

I have the following scenario: I have a file that I want to edit from certain point a certain amount of bytes.

I tried using losetup but failed:


If I loop the file entirely it works, but that's not helping me. (I'm actually keeping the C option for last since shell programming is less restrictive.

View 5 Replies View Related

Networking :: Communication Without Loopback Device

Jan 13, 2010

I have two ethernet card on my computer, I want to make a TCP or UDP communication between these two cards, so I disable loopback: #ifconfig lo down. but with out loopback I can't even ping an eth from another one. how should I do? I want traffic to really pass eth cards.

View 2 Replies View Related

Hardware :: Disk Has Many Bad Sectors (110)

Sep 7, 2010

I have some errors on my drive and I fear it may be faulty. However there are a few things I would like to try before replacing it through the manufacture or buying a new drive of my own seeing as this is a brand new computer.

Here is my computer and drive:
Acer 5251-1513 Laptop
Toshiba MK2565GSX
Running Fedora 13...now

Here is what is going on. Tried several version of Ubuntu 10.4 (studio, 64bit, 32 bit) and was having many errors during startup and having to press F to fix. Then I lost something with Gnome and the GUI would not function, and I did not know how to replace it. Tried a few other distros but could not get them to work (mostly on my part I am sure.) Then after some forum talk, thought it might just be Ubuntu unable to handle my drive. Now on Fedora 13 and a warning comes up every time I startup. "Disk has many bad sectors"

In the disk utility under the SMART Data it has 2 of the following warnings:
5- Reallocated Sector count..with a value of 72 sectors
197 Current Pending Sector count...with a value of 35 sectors
Total Bad Sectors 108.
The next day that went up to 110

I have used Fsck several times through a live CD, but the problem persists. Trying to understand bad blocks and how to write them to a file?

View 3 Replies View Related

Server :: Loopback Device - Maximum Size

Sep 24, 2010

This seems like a relatively simple question, but the answer seems to elude everyone: What is the MAXIMUM SIZE of a Linux loopback device (not counting any specific filesystem limitations)? Is it the maximum size of a linux block device?

View 4 Replies View Related

General :: Cannot Mount Hard Disk: Block Count Exceeds Size Of Device

May 11, 2011

I have one hard disk (call her HDA) that contains nothing but a single ext4 partition containing a backup of all my important data. Last night I did a clean install of Ubuntu 10.10 on my primary hard disk (call her HDB) and from there proceeded to upgrade directly to Ubuntu 11.04 upgrade. In 10.10, I was able to read HDA just fine. However after the upgrade, I can no longer mount this drive. When mounting from file browser:


Error mounting: mount: wrong fs type, bad option, bad superblock on /dev/sda,missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so The end of dmesg said the following:


dmesg | tail
[ 82.130904] EXT4-fs (sda): bad geometry: block count 122096646 exceeds size of device (122096381 blocks)

my hard disk has a block count greater than the size of my device. I've done my background searching on this and tried a command line utility I've never heard of before:


# sudo e2fsck /dev/sda
e2fsck 1.41.14 (22-Dec-2010)
The filesystem size (according to the superblock) is 122096646 blocks
The physical size of the device is 122096381 blocks


this is as far as I've gotten. This drive holds over a decade's worth of work for me and is extremely valuable. I really didn't think that the Ubuntu upgrade process would mess with this drive, seeing as the Ubuntu install was contained on an entirely different drive. What is it that I need to do to restore my drive to working status?

View 9 Replies View Related

Ubuntu :: Access Hard Disk Files From Live CD?

May 8, 2010

i'm having some problems booting ubuntu 9.10 and i just want to backup my files and install it all over again.I want to access my old files from the ubuntu Live CD, because no kernel is working.Is there a way?. Just in case, i don't have partitions, so i don't have a 'home' one (but i'm going to

View 5 Replies View Related

Ubuntu :: 2nd User Cant Access Hard Disk Drive?

Feb 2, 2011

i have one hard disk drive in my ubuntu second user is cant access that drive so wt to do to give access permission

View 1 Replies View Related

General :: Create A Growing Image For A Loopback Device

Aug 10, 2010

I was wondering if it is possible to create a growing image for a loopback device. Like a file that you create that will grow with the data that is placed on it instead of a file that has to be the size of the entire file system?

View 4 Replies View Related

SUSE / Novell :: DNS And Address / Loopback Device Lo Has Two Addresses?

Apr 19, 2010

We�re experimenting with deploying SUSE 10 SP3 systems and adding them to a Windows domain and DNS. Oddly, when we register in DNS, it gets registered under two address: the real IP address, and the address Also, an ip addr command shows that the loopback device lo has two addresses: and

The above behavior is just on SP3. On SUSE 10 SP2, the lo device has only the address, and the system is able to register correctly in DNS.

Do you know what the address signifies, or how to get rid of it?

View 3 Replies View Related

Ubuntu Installation :: Access Hard Disk Files From Live CD

May 8, 2010

I'm having some problems booting ubuntu 9.10 and I just want to backup my files and install it all over again. I want to access my old files from the ubuntu Live CD, because no kernel is working. Is there a way?. Just in case, I don't have partitions, so I don't have a 'home' one (but I'm going to).

View 1 Replies View Related

Fedora Hardware :: Added Second Disk - Bad Sectors?

Jun 19, 2010

I've just added a second disk to one of my computers. It is a 500GB SATA. It is the second drive according to the BIOS. Fedora calls it /dev/sdb. So far so good. This box is running Fedora 13 final. Never any problems until the addition of the new disk. Palimpsest says that this disk has a LOT of bad sectors. This disk is a storage drive. I want to address the problem but don't know what to do first. My thought is to rsync all the data to my external 250GB disk bedore I do anything else but I'm mot sure if I should just yet. Maybe I should run some diagnostics on the drive? If so, what? How about the tools Disk Utility offers? Should I use the Smart Utilities? What other Linux tools are available and are they reliable? Maybe I should install XP on the main disk and use Windows' disk tools? If I should lose all data it wouldn't be the end of the world but I'm not sure how "in sync" the 2 storage drives actually are.

View 10 Replies View Related

Ubuntu :: Hard Drive Sectors Lead To A Really Sluggish System?

Jul 26, 2011

My sister's laptop (toshiba satellite l550 running lucid) often runs really, really slow, even after a fresh install. Going through the gnome main menu, everything just lags by several seconds. Closing applications often takes a while, etc. I've run top and iostat to determine what the problem is and it seems to be IO-related. User processes and system processes don't take up more than a few percent, but the average load is usually over 2 even when I'm barely doing anything. Top shows that, whenever everything slows down, the 'wait' criterion is pretty high.

Now, I've also tried installing lucid to an external USB hard drive and that works fine. I'm currently running the S.M.A.R.T. diagnostic and so far I've got the attached screenshot to show. Only the criterion shown and the 'current pending sector count' are showing warnings.Any thoughts? Could the performance issue be related to the hard drive warning? I'm not planning to replace the hard drive just yet, because this laptop still has a two-year warranty.

View 8 Replies View Related

General :: Unable To Access / After Installation On New Hard Disk

Feb 18, 2010

I had very recently installed a new hard drive on my laptop. After installation, I tried to install linux from the CD and followed the instructions. I did not create a partition in the hard drive and carried out the installation procedure. After installation, i tried to start but it would not start...and shows error. I am not sure what I should do ...please instruct me in a step by step procedure to solve the problem

View 1 Replies View Related

Software :: Determine USB Hard Drive Capacity In Sectors?

Mar 24, 2011

How would one determine the capacity in sectors or LBAs of a USB Hard Drive? If I know the USB device number, like from 'lsusb', is there someplace on the system to get other information about the drive? What I want to do is have a program go out and get this information just for the number of LBAs on the drive itself. Partition info doesn't matter for what I am doing.

View 2 Replies View Related

CentOS 5 Hardware :: Unable To Access External Hard Disk?

May 31, 2010

This is Mushtaq here. I am using CentOS 5.3. Everything works fine regarding Hardware Support except of External Hard Disk. I have a HDD Western Digital 80 GB in USB converted case. Its working fine under WinOS, Fedora 10 / 11 / 12 + & RedHat Enterprise Linux. But CentOS is unable to access it even it does not detect it (fdisk -l command is used to verify the connected disks). Can any one please help me in this regard, I am fed-up of this situation.

View 1 Replies View Related

Hardware :: Master Hard Disk Error After Installing Ubuntu 8.10 / Hard Disk Died

Apr 8, 2009

after installing Ubuntu on one WD 500 GB hard disk and after making mistake and pasting wrong code into Terminal:my OTHER WD 500 GB hard disk that was also in the system (I guess it was "hd1") - died.The problem must be, I guess, I typed wrong code: "hd1,1" instead of "hd0,0".)500 GB (NTFS) of data was on that other (non-Ubuntu) hard disk, and now I can not access it anymore. While booting, system gives "Hard Disk Error" warning and stops.One again: I installed Ubuntu od one hard disk and at the end of instalation I pasted wrong code for GRUB, giving address of another hard disk. Now that other hard disk has error and will not work

View 3 Replies View Related

CentOS 5 Hardware :: Partitioning Hard Drives With 4K Sectors (WD20EARS)?

Jun 10, 2010

would anyone here happen have gotten one of these successfully up, running &, aligned on 5.5? i only want two partitions. one 2gig for swap and the rest mounted @ /. i've googled myself into complete and utter confusion.[Moderator edit: changed the title to something more informative

View 4 Replies View Related

OpenSUSE Network :: Access Shared Hard Disk Windows 7 Home And 11.2

Mar 1, 2010

I have a hardisk shared on my windows machine. And I would like to be able to access this on my opensuse notebook. Just cant figure it out. Dont have much experience in opensuse. I just need to know the best way to do this. Also, can opensuse read/write NTFS? Also I have a printer on my moms machine that runs XP home. The printer is shared I would like to be able to print but its no biggie. It some type of HP 3 in 1. I just wnat it to print, I dont care about the scanner and stuff.

View 3 Replies View Related

Ubuntu Installation :: Copy Hard Disk Have 10.04 And Ext4 To 1000 Hard Disk?

Sep 23, 2010

I want to copy hard disk have ubuntu 10.04 and ext4 to 1000 hard disk for new 1000

View 2 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved