1# @ohos.file.volumeManager (Volume Management) (System API) 2<!--Kit: Core File Kit--> 3<!--Subsystem: FileManagement--> 4<!--Owner: @wang_zhangjun; @zhuangzhuang--> 5<!--Designer: @wang_zhangjun; @zhuangzhuang; @renguang1116--> 6<!--Tester: @liuhonggang123; @yue-ye2; @juxiaopang--> 7<!--Adviser: @foryourself--> 8 9The **volumeManager** module provides APIs for querying and managing volumes and disks, including querying volume information, mounting or unmounting a volume, partitioning a disk, and formatting a volume. 10 11> **NOTE** 12> 13> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 14> - The APIs provided by this module are system APIs. 15 16## Modules to Import 17 18```ts 19import volumemanager from "@ohos.file.volumeManager"; 20``` 21 22## volumemanager.getAllVolumes 23 24getAllVolumes(): Promise<Array<Volume>> 25 26Obtains information about all volumes of this external storage device. This API uses a promise to return the result. 27 28**Required permissions**: ohos.permission.STORAGE_MANAGER 29 30**System capability**: SystemCapability.FileManagement.StorageService.Volume 31 32**Return value** 33 34 | Type | Description | 35 | ---------------------------------- | -------------------------- | 36 | Promise<[Volume](#volume)[]> | Promise used to return the information about all available volume devices.| 37 38**Error codes** 39 40For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 41 42| ID| Error Message| 43| -------- | -------- | 44| 201 | Permission verification failed. | 45| 202 | The caller is not a system application. | 46| 401 | The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified. | 47| 13600001 | IPC error. | 48| 13900042 | Unknown error. | 49 50**Example** 51 52 ```ts 53 import { BusinessError } from '@ohos.base'; 54 volumemanager.getAllVolumes().then((volumes: Array<volumemanager.Volume>) => { 55 // do something with volumes, which is an array 56 }).catch((error: BusinessError) => { 57 console.error("getAllVolumes failed"); 58 }); 59 ``` 60 61## volumemanager.getAllVolumes 62 63getAllVolumes(callback: AsyncCallback<Array<Volume>>): void 64 65Obtains information about all volumes of this external storage device. This API uses an asynchronous callback to return the result. 66 67**Required permissions**: ohos.permission.STORAGE_MANAGER 68 69**System capability**: SystemCapability.FileManagement.StorageService.Volume 70 71**Parameters** 72 73 | Name | Type | Mandatory| Description | 74 | -------- | ------------------------------------------------- | ---- | ------------------------------------ | 75 | callback | AsyncCallback<[Volume](#volume)[]> | Yes | Callback used to return information about all available volumes.| 76 77**Error codes** 78 79For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 80 81| ID| Error Message| 82| -------- | -------- | 83| 201 | Permission verification failed. | 84| 202 | The caller is not a system application. | 85| 401 | The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified. | 86| 13600001 | IPC error. | 87| 13900042 | Unknown error. | 88 89**Example** 90 91 ```ts 92 import { BusinessError } from '@ohos.base'; 93 volumemanager.getAllVolumes((error: BusinessError, volumes: Array<volumemanager.Volume>) => { 94 // Do something. 95 }); 96 ``` 97 98## volumemanager.mount 99 100mount(volumeId: string): Promise<void> 101 102Mounts a volume. This API uses a promise to return the result. Currently, only the FAT, exFAT, and NTFS file systems are supported. 103 104**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 105 106**System capability**: SystemCapability.FileManagement.StorageService.Volume 107 108**Parameters** 109 110 | Name | Type | Mandatory| Description| 111 | -------- | ------ | ---- | ---- | 112 | volumeId | string | Yes | Volume ID.| 113 114**Return value** 115 116 | Type | Description | 117 | ---------------------- | ---------- | 118 | Promise<void> | Promise that returns no value.| 119 120**Error codes** 121 122For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 123 124| ID| Error Message| 125| -------- | -------- | 126| 201 | Permission verification failed. | 127| 202 | The caller is not a system application. | 128| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 129| 13600001 | IPC error. | 130| 13600002 | Not supported filesystem. | 131| 13600003 | Failed to mount. | 132| 13600005 | Incorrect volume state. | 133| 13600008 | No such object. | 134| 13900042 | Unknown error. | 135 136**Example** 137 138 ```ts 139 import { BusinessError } from '@ohos.base'; 140 let volumeId: string = ""; 141 volumemanager.mount(volumeId).then(() => { 142 // Do something. 143 }).catch((error: BusinessError) => { 144 console.error("mount failed"); 145 }); 146 ``` 147 148## volumemanager.mount 149 150mount(volumeId: string, callback:AsyncCallback<void>):void 151 152Mounts a volume. This API uses an asynchronous callback to return the result. Currently, only the FAT, exFAT, and NTFS file systems are supported. 153 154**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 155 156**System capability**: SystemCapability.FileManagement.StorageService.Volume 157 158**Parameters** 159 160 | Name | Type | Mandatory| Description | 161 | -------- | ------------------------------------- | ---- | -------------------- | 162 | volumeId | string | Yes | Volume ID. | 163 | callback | AsyncCallback<void> | Yes | Callback invoked when the specified volume is mounted.| 164 165**Error codes** 166 167For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 168 169| ID| Error Message| 170| -------- | -------- | 171| 201 | Permission verification failed. | 172| 202 | The caller is not a system application. | 173| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 174| 13600001 | IPC error. | 175| 13600002 | Not supported filesystem. | 176| 13600003 | Failed to mount. | 177| 13600005 | Incorrect volume state. | 178| 13600008 | No such object. | 179| 13900042 | Unknown error. | 180 181**Example** 182 183 ```ts 184 import { BusinessError } from '@ohos.base'; 185 let volumeId: string = ""; 186 volumemanager.mount(volumeId, (error: BusinessError) => { 187 // Do something. 188 }); 189 ``` 190 191## volumemanager.unmount 192 193unmount(volumeId: string): Promise<void> 194 195Unmounts a volume. This API uses a promise to return the result. 196 197**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 198 199**System capability**: SystemCapability.FileManagement.StorageService.Volume 200 201**Parameters** 202 203 | Name | Type | Mandatory| Description| 204 | -------- | ------ | ---- | ---- | 205 | volumeId | string | Yes | Volume ID.| 206 207**Return value** 208 209 | Type | Description | 210 | ---------------------- | ---------- | 211 | Promise<void> | Promise that returns no value.| 212 213**Error codes** 214 215For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 216 217| ID| Error Message| 218| -------- | -------- | 219| 201 | Permission verification failed. | 220| 202 | The caller is not a system application. | 221| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 222| 13600001 | IPC error. | 223| 13600002 | Not supported filesystem. | 224| 13600004 | Failed to unmount. | 225| 13600005 | Incorrect volume state. | 226| 13600008 | No such object. | 227| 13900042 | Unknown error. | 228 229**Example** 230 231 ```ts 232 import { BusinessError } from '@ohos.base'; 233 let volumeId: string = ""; 234 volumemanager.unmount(volumeId).then(() => { 235 // Do something. 236 }).catch((error: BusinessError) => { 237 console.error("mount failed"); 238 }); 239 ``` 240 241## volumemanager.unmount 242 243unmount(volumeId: string, callback: AsyncCallback<void>): void 244 245Unmounts a volume. This API uses an asynchronous callback to return the result. 246 247**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 248 249**System capability**: SystemCapability.FileManagement.StorageService.Volume 250 251**Parameters** 252 253 | Name | Type | Mandatory| Description | 254 | -------- | ------------------------------------- | ---- | -------------------- | 255 | volumeId | string | Yes | Volume ID. | 256 | callback | AsyncCallback<void> | Yes | Callback invoked when the specified volume is unmounted.| 257 258**Error codes** 259 260For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 261 262| ID| Error Message| 263| -------- | -------- | 264| 201 | Permission verification failed. | 265| 202 | The caller is not a system application. | 266| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 267| 13600001 | IPC error. | 268| 13600002 | Not supported filesystem. | 269| 13600004 | Failed to unmount. | 270| 13600005 | Incorrect volume state. | 271| 13600008 | No such object. | 272| 13900042 | Unknown error. | 273 274**Example** 275 276 ```ts 277 import { BusinessError } from '@ohos.base'; 278 let volumeId: string = ""; 279 volumemanager.unmount(volumeId, (error: BusinessError) => { 280 // Do something. 281 }); 282 ``` 283 284## volumemanager.getVolumeByUuid 285 286getVolumeByUuid(uuid: string): Promise<Volume> 287 288Obtains information about a volume based on the universally unique identifier (UUID). This API uses a promise to return the result. 289 290**Required permissions**: ohos.permission.STORAGE_MANAGER 291 292**System capability**: SystemCapability.FileManagement.StorageService.Volume 293 294**Parameters** 295 296 | Name | Type | Mandatory| Description| 297 | -------- | ------ | ---- | ---- | 298 | uuid | string | Yes | UUID of the volume.| 299 300**Return value** 301 302 | Type | Description | 303 | ---------------------------------- | -------------------------- | 304 | Promise<[Volume](#volume)> | Promise used to return the information about all available volume devices.| 305 306**Error codes** 307 308For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 309 310| ID| Error Message| 311| -------- | -------- | 312| 201 | Permission verification failed. | 313| 202 | The caller is not a system application. | 314| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 315| 13600001 | IPC error. | 316| 13600008 | No such object. | 317| 13900042 | Unknown error. | 318 319**Example** 320 321 ```ts 322 import { BusinessError } from '@ohos.base'; 323 let uuid: string = ""; 324 volumemanager.getVolumeByUuid(uuid).then((volume: volumemanager.Volume) => { 325 console.info("getVolumeByUuid successfully:" + JSON.stringify(volume)); 326 }).catch((error: BusinessError) => { 327 console.error("getVolumeByUuid failed with error:" + JSON.stringify(error)); 328 }); 329 ``` 330 331## volumemanager.getVolumeByUuid 332 333getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void 334 335Obtains information about a volume based on the UUID. This API uses an asynchronous callback to return the result. 336 337**Required permissions**: ohos.permission.STORAGE_MANAGER 338 339**System capability**: SystemCapability.FileManagement.StorageService.Volume 340 341**Parameters** 342 343 | Name | Type | Mandatory| Description | 344 | -------- | ------------------------------------------------ | ---- | -------------------- | 345 | uuid | string | Yes | UUID of the volume. | 346 | callback | AsyncCallback<[Volume](#volume)> | Yes | Callback used to return the volume information obtained.| 347 348**Error codes** 349 350For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 351 352| ID| Error Message| 353| -------- | -------- | 354| 201 | Permission verification failed. | 355| 202 | The caller is not a system application. | 356| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 357| 13600001 | IPC error. | 358| 13600008 | No such object. | 359| 13900042 | Unknown error. | 360 361**Example** 362 363 ```ts 364 import { BusinessError } from '@ohos.base'; 365 let uuid: string = ""; 366 volumemanager.getVolumeByUuid(uuid, (error: BusinessError, volume: volumemanager.Volume) => { 367 // Do something. 368 }); 369 ``` 370 371## volumemanager.getVolumeById 372 373getVolumeById(volumeId: string): Promise<Volume> 374 375Obtains information about a volume based on the volume ID. This API uses a promise to return the result. 376 377**Required permissions**: ohos.permission.STORAGE_MANAGER 378 379**System capability**: SystemCapability.FileManagement.StorageService.Volume 380 381**Parameters** 382 383 | Name | Type | Mandatory | Description| 384 | -------- | ------ | ---- | ---- | 385 | volumeId | string | Yes | Volume ID.| 386 387**Return value** 388 389 | Type | Description | 390 | ---------------------------------- | -------------------------- | 391 | Promise<[Volume](#volume)> | Promise used to return the information about all available volume devices.| 392 393**Error codes** 394 395For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 396 397| ID| Error Message| 398| -------- | -------- | 399| 201 | Permission verification failed. | 400| 202 | The caller is not a system application. | 401| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 402| 13600001 | IPC error. | 403| 13600008 | No such object. | 404| 13900042 | Unknown error. | 405 406**Example** 407 408 ```ts 409 import { BusinessError } from '@ohos.base'; 410 let volumeId: string = ""; 411 volumemanager.getVolumeById(volumeId).then((volume: volumemanager.Volume) => { 412 console.info("getVolumeById successfully:" + JSON.stringify(volume)); 413 }).catch((error: BusinessError) => { 414 console.error("getVolumeById failed with error:" + JSON.stringify(error)); 415 }); 416 ``` 417 418## volumemanager.getVolumeById 419 420getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void 421 422Obtains information about a volume based on the volume ID. This API uses an asynchronous callback to return the result. 423 424**Required permissions**: ohos.permission.STORAGE_MANAGER 425 426**System capability**: SystemCapability.FileManagement.StorageService.Volume 427 428**Parameters** 429 430 | Name | Type | Mandatory| Description | 431 | -------- | ------------------------- | ---- | ----------------------------- | 432 | volumeId | string | Yes | Volume ID. | 433 | callback | AsyncCallback<[Volume](#volume)> | Yes | Callback used to return the volume information obtained. | 434 435**Error codes** 436 437For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 438 439| ID| Error Message| 440| -------- | -------- | 441| 201 | Permission verification failed. | 442| 202 | The caller is not a system application. | 443| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 444| 13600001 | IPC error. | 445| 13600008 | No such object. | 446| 13900042 | Unknown error. | 447 448**Example** 449 450 ```ts 451 import { BusinessError } from '@ohos.base'; 452 let volumeId: string = ""; 453 volumemanager.getVolumeById(volumeId, (error: BusinessError, volume: volumemanager.Volume) => { 454 // Do something. 455 }); 456 ``` 457 458## volumemanager.setVolumeDescription 459 460setVolumeDescription(uuid: string, description: string): Promise<void> 461 462Sets volume description. This API uses a promise to return the result. 463 464**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 465 466**System capability**: SystemCapability.FileManagement.StorageService.Volume 467 468**Parameters** 469 470 | Name | Type | Mandatory| Description| 471 | --------- | ------ | ---- | ---- | 472 | uuid | string | Yes | UUID of the volume.| 473 | description | string | Yes | Description of the volume.| 474 475**Return value** 476 477 | Type | Description | 478 | ---------------------- | -------------------------- | 479 | Promise<void> | Promise that returns no value. | 480 481**Error codes** 482 483For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 484 485| ID| Error Message| 486| -------- | -------- | 487| 201 | Permission verification failed. | 488| 202 | The caller is not a system application. | 489| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 490| 13600001 | IPC error. | 491| 13600002 | Not supported filesystem. | 492| 13600005 | Incorrect volume state. | 493| 13600008 | No such object. | 494| 13900042 | Unknown error. | 495 496**Example** 497 498 ```ts 499 import { BusinessError } from '@ohos.base'; 500 let uuid: string = ""; 501 let description: string = ""; 502 volumemanager.setVolumeDescription(uuid, description).then(() => { 503 console.info("setVolumeDescription successfully"); 504 }).catch((error: BusinessError) => { 505 console.error("setVolumeDescription failed with error:" + JSON.stringify(error)); 506 }); 507 ``` 508 509## volumemanager.setVolumeDescription 510 511setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void 512 513Sets volume description. This API uses an asynchronous callback to return the result. 514 515**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER 516 517**System capability**: SystemCapability.FileManagement.StorageService.Volume 518 519**Parameters** 520 521 | Name | Type | Mandatory| Description | 522 | ---------- | --------------------------------------- | ---- | ---------------- | 523 | uuid | string | Yes | UUID of the volume. | 524 | description | string | Yes | Description of the volume. | 525 | callback | AsyncCallback<void> | Yes | Callback invoked after the volume description is set.| 526 527**Error codes** 528 529For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 530 531| ID| Error Message| 532| -------- | -------- | 533| 201 | Permission verification failed. | 534| 202 | The caller is not a system application. | 535| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 536| 13600001 | IPC error. | 537| 13600002 | Not supported filesystem. | 538| 13600005 | Incorrect volume state. | 539| 13600008 | No such object. | 540| 13900042 | Unknown error. | 541 542**Example** 543 544 ```ts 545 import { BusinessError } from '@ohos.base'; 546 let uuid: string = ""; 547 let description: string = ""; 548 volumemanager.setVolumeDescription(uuid, description, (error: BusinessError) => { 549 // Do something. 550 }); 551 ``` 552 553## volumemanager.format 554 555format(volumeId: string, fsType: string): Promise<void> 556 557Formats a volume. This API uses a promise to return the result. Currently, only the virtual file allocation table (VFAT) and exFAT file systems are supported. Only unmounted volumes can be formatted. After a volume is formatted, the UUID, mounting path, and description of the volume will change. 558 559**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER 560 561**System capability**: SystemCapability.FileManagement.StorageService.Volume 562 563**Parameters** 564 565 | Name | Type | Mandatory| Description| 566 | ----------- | ------ | ---- | ---- | 567 | volumeId | string | Yes | Volume ID.| 568 | fsType | string | Yes | File system type, which can be VFAT or exFAT.| 569 570**Return value** 571 572 | Type | Description | 573 | ---------------------- | ---------- | 574 | Promise<void> | Promise that returns no value.| 575 576**Error codes** 577 578For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 579 580| ID| Error Message| 581| -------- | -------- | 582| 201 | Permission verification failed. | 583| 202 | The caller is not a system application. | 584| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 585| 13600001 | IPC error. | 586| 13600002 | Not supported filesystem. | 587| 13600005 | Incorrect volume state. | 588| 13600008 | No such object. | 589| 13900042 | Unknown error. | 590 591**Example** 592 593 ```ts 594 import { BusinessError } from '@ohos.base'; 595 let volumeId: string = ""; 596 let fsType: string = ""; 597 volumemanager.format(volumeId, fsType).then(() => { 598 console.info("format successfully"); 599 }).catch((error: BusinessError) => { 600 console.error("format failed with error:" + JSON.stringify(error)); 601 }); 602 ``` 603 604## volumemanager.format 605 606format(volumeId: string, fsType: string, callback: AsyncCallback<void>): void 607 608Formats a volume. This API uses an asynchronous callback to return the result. Currently, only the VFAT and exFAT file systems are supported. Only unmounted volumes can be formatted. After a volume is formatted, the UUID, mounting path, and description of the volume will change. 609 610**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER 611 612**System capability**: SystemCapability.FileManagement.StorageService.Volume 613 614**Parameters** 615 616 | Name | Type | Mandatory| Description | 617 | -------- | ------------------------- | ---- | ----------------------------- | 618 | volumeId | string | Yes | Volume ID. | 619 | fsType | string | Yes | File system type, which can be VFAT or exFAT.| 620 | callback | AsyncCallback<void> | Yes | Callback that returns no value. | 621 622**Error codes** 623 624For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 625 626| ID| Error Message| 627| -------- | -------- | 628| 201 | Permission verification failed. | 629| 202 | The caller is not a system application. | 630| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 631| 13600001 | IPC error. | 632| 13600002 | Not supported filesystem. | 633| 13600005 | Incorrect volume state. | 634| 13600008 | No such object. | 635| 13900042 | Unknown error. | 636 637**Example** 638 639 ```ts 640 import { BusinessError } from '@ohos.base'; 641 let volumeId: string = ""; 642 let fsType: string = ""; 643 volumemanager.format(volumeId, fsType, (error: BusinessError) => { 644 // Do something. 645 }); 646 ``` 647 648## volumemanager.partition 649 650partition(diskId: string, type: number): Promise<void> 651 652Partitions a disk. This API uses a promise to return the result. The system supports access to multi-partition disks. Currently, this API can partition a disk into only one partition. 653 654**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER 655 656**System capability**: SystemCapability.FileManagement.StorageService.Volume 657 658**Parameters** 659 660 | Name | Type | Mandatory| Description| 661 | ----------- | ------ | ---- | ---- | 662 | diskId | string | Yes | ID of the disk to partition.| 663 | type | number | Yes | Partition type. | 664 665**Return value** 666 667 | Type | Description | 668 | --------------------- | ----------------------- | 669 | Promise<void> | Promise that returns no value. | 670 671**Error codes** 672 673For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 674 675| ID| Error Message| 676| -------- | -------- | 677| 201 | Permission verification failed. | 678| 202 | The caller is not a system application. | 679| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 680| 13600001 | IPC error. | 681| 13600008 | No such object. | 682| 13900042 | Unknown error. | 683 684**Example** 685 686 ```ts 687 import { BusinessError } from '@ohos.base'; 688 let diskId: string = ""; 689 let type: number = 0; 690 volumemanager.partition(diskId, type).then(() => { 691 console.info("partition successfully"); 692 }).catch((error: BusinessError) => { 693 console.error("partition failed with error:" + JSON.stringify(error)); 694 }); 695 ``` 696 697## volumemanager.partition 698 699partition(diskId: string, type: number, callback: AsyncCallback<void>): void 700 701Partitions a disk. This API uses a callback to return the result. The system supports access to multi-partition disks. Currently, this API can partition a disk into only one partition. 702 703**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER 704 705**System capability**: SystemCapability.FileManagement.StorageService.Volume 706 707**Parameters** 708 709 | Name | Type | Mandatory| Description | 710 | -------- | --------------------------------------- | ---- | ---------------- | 711 | diskId | string | Yes | ID of the disk to partition. | 712 | type | number | Yes | Partition type. | 713 | callback | AsyncCallback<void> | Yes | Callback that returns no value. | 714 715**Error codes** 716 717For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md). 718 719| ID| Error Message| 720| -------- | -------- | 721| 201 | Permission verification failed. | 722| 202 | The caller is not a system application. | 723| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 724| 13600001 | IPC error. | 725| 13600008 | No such object. | 726| 13900042 | Unknown error. | 727 728**Example** 729 730 ```ts 731 import { BusinessError } from '@ohos.base'; 732 let diskId: string = ""; 733 let type: number = 0; 734 volumemanager.partition(diskId, type, (error: BusinessError) => { 735 // Do something. 736 }); 737 ``` 738 739## Volume 740 741**System capability**: SystemCapability.FileManagement.StorageService.Volume 742 743### Attributes 744 745| Name | Type | Read-Only | Optional | Description | 746| ----------- | ------- | ------- | ----- | -------------------- | 747| id | string | No| No| Volume ID, in the vol-{Primary device ID}-{Secondary device ID} format. The primary device IDs identify devices of different types. The secondary device IDs identify different devices of the same type. The volume IDs vary depending on the card insertion sequence. | 748| uuid | string | No| No| Volume UUID, which uniquely identifies a volume irrespective of the card insertion sequence. However, the UUID of a volume will change after the volume is formatted. | 749| diskId | string | No| No| ID of the disk to which the volume belongs. A disk can have one or more volumes. The disk ID is in the disk-{Primary device ID}-{Secondary device ID} format, which is similar to the volume ID. | 750| description | string | No| No| Description of the volume. | 751| removable | boolean | No| No| Whether the volume can be removed. Currently, only removable storage devices are supported. The value **true** means the device can be removed; the value **false** means the opposite.| 752| state | number | No| No| Volume status.<br>**0**: The volume is unmounted.<br> **1**: The volume is being checked.<br> **2**: The volume is mounted.<br> **3**: The volume is being ejected. | 753| path | string | No| No| Path of the volume mounted. Generally, the path is **/mnt/data/external/{uuid}**. | 754| fsType<sup>12+</sup> | string | No| No| File system type. Common file systems are **ext2**, **vfat**, and **NTFS**. | 755